Which are keywords in Java?
A. NULL
B. sizeof
C. friend
D. extends
E. synchronized
请选择: A B C D E
答案:D E
public class X{
public static void main(String[] args){
int[] a=new int[1];
4) modify(a);
System.out.println(a[0]);
}
public static void modify(int[] a){
9) a[0]++;}
}
what is the result?
A.The program runs and prints "0";
B.The program runs and prints "1";
C.The program runs but aborts with an exception;
D.An error "possible undefined variable" at line 4 cause compilation to fail;
E.An error "possible undefined variable" at line 9 cause compilation to fail;
请选择: A B C D E
答案:B
An object is ...
A) what classes are instantiated from.
B) an instance of a class.
C) a blueprint for creating concrete realization of abstractions.
D) a reference to an attribute.
E) a variable.
请选择: A B C D
答案:B
Which of the following statements about variables and their scopes are true?
A. Instance variables are member variables of a class.
B. Instance variables are declared with the static keyword.
C. Local variables defined inside a method are created when the method is executed.
D. Local variables must be initialized before they are used.
请选择: A B C D
答案:A C D
点评:类中有几种变量,分别是:局部变量(英文可以为:localautomatic emporarystack variable)是定义在方法里的变量;实例变量(英文为:instance variable)是在方法外而在类声明内定义的变量,有时也叫成员变量;类变量(英文为:class variable)是用关键字static声明的实例变量,他们的生存期分别是:局部变量在定义该变量的方法被调用时被创建,而在该方法退出后被撤销;实例变量在使用new Xxxx()创建该类的实例时被创建,而其生存期和该类的实例对象的生存期相同;类变量在该类被加载时被创建,不一定要用new Xxxx()创建,所有该类的实例对象共享该类变量,其生存期是类的生存期。任何变量在使用前都必须初始化,但是需要指出的是局部变量必须显式初始化,而实例变量不必,原始类型的实例变量在该类的构造方法被调用时为它分配的缺省的值,整型是0,布尔型是false,而浮点型是0.0f,引用类型(类类型)的实例变量的缺省值是null(没有进行实际的初始化,对它的使用将引起NullPointException),类变量的规则和实例变量一样,不同的是类变量的初始化是在类被加载时。
SCJP测试答案
如果你认为试题或答案有误,请你在留言板中通知站长!!
第29题(id号:150)
public class X{
private static int a;
public static void main(String[] args){
modify(a);
System.out.println(a);
}
public static void modify(int a){
a++;
}
}
what is the result?
A. 0
B. 1
请选择: A B
答案:A
Given the following expression about List.
List l = new List(6,true);
Which statements are ture?
A. The visible rows of the list is 6 unless otherwise constrained.
B. The maximum number of characters in a line will be 6.
C. The list allows users to make multiple selections
D. The list can be selected only one item.
请选择: A B C D
答案:A C
点评: List组件的该构造方法的第一个参数的意思是它的初始显式行数,如果该值为0则显示4行,第二个参数是指定该组件是否可以多选,如果值为true则是可以多选,如果不指定则缺省是不能多选。
The argument for a class's main() method is called args, and the class is invoked
as follows. java Example cat
What would be the effect of trying to access args[0] in the main method?
A. The value produced is cat
B. The value produced is java
C. The value produced is Example
D. An object of type NullPointerException is thrown.
E. An object of type ArrayIndexOutofBoundsException is thrown.
请选择: A B C D E
答案:A
点评:命令行参数是紧跟在类名后面的。所以本题中参数由“cat”提供。
Given the following code, which statements concerning the objects referenced
through the member variables i, j and k are true, given that any thread may
call the methods a, b and c at any time?
class Counter {
int v = 0;
synchronized void inc() { v++; }
synchronized void dec() { v--; }
}
public class Q7ed5 {
Counter i;
Counter j;
Counter k;
public synchronized void a() {
i.inc();
System.out.println("a");
i.dec();
}
public synchronized void b() {
i.inc();
j.inc();
k.inc();
System.out.println("b");
i.dec();
j.dec();
k.dec();
}
public void c() {
k.inc();
System.out.println("c");
k.dec();
}
}
A) i.v is guaranteed always to be 0 or 1.
B) j.v is guaranteed always to be 0 or 1.
C) k.v is guaranteed always to be 0 or 1
D) j.v will always be greater than or equal to k.v at any give time.
E) k.v will always be greater than or equal to j.v at any give time.
请选择: A B C D E
答案:A B
Which three are valid declarations of a float? (Choose Three)
A. float foo = -1;
B. float foo = 1.0;
C. float foo = 42e1;
D. float foo = 2.02f;
E. float foo = 3.03d;
F. float foo = 0x0123;
请选择: A B C D E F
答案:A D F
What will happen when we try to compile the following code.
1. public void WhichArray( Object x ) {
2. if( x instanceof int[] ) {
3. int[] n = (int[]) x ;
4. for( int i = 0 ; i < n.length ; i++ ){
5. System.out.println("integers = " +n[i] );
6. }
7. }
8. if( x instanceof String[] ) {
9. System.out.println("Array of Strings");
10. }
11. }
a. The compiler objects to line 2 comparing an Object with an array.
b. The compiler objects to line 3 casting an Object to an array of int primitives.
c. The compiler objects to line 7 comparing an Object to an array of Objects.
d. It compiles without error.
请选择: A B C D
答案:D
分享到:
相关推荐
Java 自测试题,适合java自学者的学习检测,也可作为招聘时的练习题
《Java测试题2》 <br>一、 选择 1.欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的 ? B A ArrayList myList=new Object(); B List myList=new ArrayList(); C ...
java初级语法测试题,
Java 技能测试题Java 技能测试题
java测试题java测试题
JAVA高级程序设计测试题含答案 JAVA高级程序设计测试题含答案 160题_共320.00分_及格260.00分 您的姓名: [填空题] * _________________________________ 第1题 【单选题】【2.00分】【概念理解】 在程序读入字符...
Java测试题 用于检测学习效果的一个小测验!
杰普 Core Java测试题 附答案 答案是标准答案,有选择题也有编程题
属于北大青鸟Y2Java方向结业测试模拟题 包含源码
《Java测试题1》 Java培训后考试 一、 是非题5题(每题3分) 1、 对象的特征是对象有状态、行为、标识ID ( ) 2、 GenericServlet是一个与协议相关的Servlet类。 ( ) 3、 Java中的this指的是当前类...
Java应用程序-题库测试题练习题带答案测试题模拟题自测题.doc
java期末测试题,是各种大学院校复习的资料
广州传智播客JavaEE工程师测试题(带答案的).doc 应聘时最漂亮的回答.docx 当面试官问「你有什么要问我的吗」时,应该问什么?.docx 提高 Java 代码性能的各种技巧.docx 搜狗商业平台Java技术实践.docx 最新JAVA...
javacore测试题及参考答案javacore测试题及参考答案
这是我找java软件工程师时候,收集的java面试题,汇集了主要的试题,实际我在笔试中有80%的内容和这里面的是重复的.希望能帮助找java工作的您. EJB方面.doc java.doc Java中文问题详解(高手必读).txt Java中文问题...
包含数据结构绪论,线性表,树,图,查找,排序各章节自测题及详细答案,供在校计算机学生考试复习使用
这是Java基础知识的一套判断题,在学习和复习Java的是时候可以用来进行模拟测试,检测一下自己的能力,用来备考。
ACCp6.0 Java 内部测试题 第二本书学完测试
键盘录入5个学生信息(姓名,语文成绩,数学成绩,英语成绩),按照总分从高到低输出到控制台java 集合练习题
北大高科java测试题