问答题写出下面的程序编译、运行后的结果(6分)。 public class Test public static void main(String args[]) new Student("Tom", 'm', 90, 88); new Student("Jack", 'm', 66, 89); new Student("Mary", 'f', 76, 86); System.out.println("name/tsex/tchinese/tenglish"); Student.print(); class Student protected String name; protected char sex; protected int chinese; protected int english; protected Student next; static Student list; Student(String name, char sex, int chinese, int english) this.name=name; this.sex=sex; this.chinese=chinese; this.english=english; this.next=list; list=this; static void print() Student friend=list; if(friend==null) System.out.println("The list is empty."); else do System.out.println(friend.toString()); friend=friend.next; while(friend!=null); public String toString() return new String(name+"/t"+sex+"/t"+chinese+"/t"+english);
问答题编写一个字符界面的Java Application 程序,接受用户输入的10个整数,并输出这10个整数的最大值和最小值。
问答题阅读下面的程序,并回答问题(①问3分,②问3分,共6分)。 import java.io.*; public class Test public static void main(String args[]) throws IOException BufferedReader buf=new BufferedReader( new InputStreamReader(System.in)); while(true) String str=buf.readLine______; if(str.equals("quit")) break; int x=Integer.parseInt(str); System.out.println(x*x); 编译运行上面的程序: ①从键盘输入5,回车后输出的结果如何? ②从键盘输入quit,回车后程序执行情况如何?
问答题按以下要求编写程序 (1) 创建一个Rectangle类,添加width和height两个成员变量 (2) 在Rectangle中添加两种方法分别计算矩形的周长和面积 (3) 编程利用Rectangle输出一个矩形的周长和面积
多选题Objects are passed by ______.
A. Value
B. Sum
C. Reference
D. Pointer
多选题Given: public class ArithmeticResultsOutput
{ public static void main(String[] args {
inti1=100; intj1= 200; if((i1==99) }
else { System.out.print("Value2: "+(i1+j1+" ");
} inti2=100; intj2=200; if((i2==99)
} else { System.out.print("Value2:
"+(i2+j2+" "); } inti3=100;
intj3=200; if((i3==100) | (--j3==200)) {
System.out.print("Value1: "+(i3+j3+" "); } else {
System.out.print("Value2: "+(i3+j3+" "); }
inti4=100; intj4=200; if((i4==100) || (--j4==200))
{ System.out.print("Value1: "+(i4+j4+" "); }
else { System.out.print("Value2: "+(i4+j4+" ");
} } } What will be
printed to standard out?
A. Value2: 300 Value2: 300 Value1: 300 Value1: 300
B. Value2: 299 Value2: 300 Value1: 299 Value1: 300
C. Value1: 299 Value1: 300 Value2: 299 Value2: 300
D. Value1: 300 Value1: 299 Value2: 300 Value2:
299
多选题下面说法正确的是______。 A.如果某公共接口被声明在一个源文件中,则接口必须与源文件具有相同名字。 B.如果源文件包含import语句,则该语句必须是除空行和注释行外的第一个语句行。 C.如果某源文件包含package语句,则该语句必须是第一个非空、非注释行。 D.接口中的方法必定是抽象方法,但可以不用关键字abstract修饰。
多选题Given the SampleClass, when the following code segment is executed,
what is the value of the instance variable size? SampleClass
sampleClass = new SampleClass(5); public class SampleClass
{ private int size; public SampleClass(int
size) { size = size; } }
A. 0
B. 1
C. 5
D. Compiler error
E. Runtime error
多选题What is the difference between an int and an Integer?
A. Nothing. They are both fully interchangeable.
B. An int is an object and Integer is a primitive. An int is fastest when
performing calculations.
C. An int is a primitive and Integer is an object. An int is fastest when
performing calculations.
D. This is a trick question. There is no such thing as an Integer.
E. This is a trick question. An Integer can be defined to be anything a
developer wants it to be.
多选题What array type has the most overhead?
A. One-dimensional array
B. Multi-dimensional array
C. ArrayList
多选题下面main______方法的定义哪些是正确的______? A.public static void main(String args[]) B.public static void main(String[]) C.public static void main(String[] args) D.public static void main(String [] x)
多选题Primitives are passed by ______.
A. Value
B. Sum
C. Reference
D. Pointer
多选题下面关于Java中异常处理try块的说法正确的是______? A.try块后通常应有一个catch 块,用来处理try块中抛出的异常。 B.catch 块后必须有finally块。 C.可能抛出异常的方法调用应放在try块中。 D.对抛出的异常的处理必须放在try块中
多选题A method needs to be created that accepts an array of floats as an
argument and does not return any variables. The method should be called
setPoints. Which of the following method declarations is correct?
A. setPoints(float[] points) {...}
B. void setPoints(float points) {...}
C. void setPoints(float[] points) {...}
D. float setPoints(float[] points) {...}
多选题Which of the following is the only Java package that is imported by
default?
A. java.awt
B. java.lang
C. java.util
D. java.io
多选题类B是一个抽象类,类C是类B的非抽象子类,下列创建对象x1的语句中正确的是( )。 A.B x1= new B( ); B.B x1= new C( ); C.C x1=new C( ); D.C x1= new B( );
多选题Considerthefollowingillustration.Whichstatements,alsorepresentedintheillustration,aretrue?A.TheStringclassimplementstheObjectinterface.B.TheStringclassimplementstheComparable,Serializable,andCharSequenceinterfaces.C.ThetoStringmethodoverridesthetoStringmethodoftheObjectclass,allowingtheStringobjecttoreturnitsownstring.D.ThetoStringmethodispubliclyaccessible.
多选题You need to create a class to store information about books contained
in a library. What variable scope is best suited for the variable that will
store the title of a book?
A. Local variable
B. Static variable
C. Global variable
D. Method parameter
E. Instance variable
多选题Given the SampleClass, what is the output of this code
segment? SampleClass sampleClass = new SampleClass();
public class SampleClass { private int size;
public SampleClass() { this(1);
System.out.println("Using default values"); }
public SampleClass(int size) { this.size = size;
System.out.println("Setting size"); } }
A. Using default values
B. Setting size
C. Using default values Setting size
D. Setting size Using default values
E. Compiler error
多选题Which statement would designate that your file belongs in the package
com. ocajexam.utilities?
A. pack com.ocajexam.utilities;
B. Package com.ocajexam.utilities.*
C. package com.ocajexam.utilities.*;
D. package com.ocajexam.utilities;
