J2EE训前

31.

Which will declare a method that is available to all members of the same package and

can be referenced without an instance of the class?    (该题为必答题)

标记为待复查 
(2) 分数

Public abstract double methoda();

 

Abstract public void methoda();

 

Static void methoda(double d1){}

 

 

 

32.

Which type of event indicates a key pressed on a java.awt.Component?    (该题为必答题)

标记为待复查 
(2) 分数

KeyEvent

 

KeyPressEvent

 

KeyTypedEvent

 

KeyDownEvent

 

 

 

33.

Given:

1. public class Test {

2. public static void main (String [] args) {

3. string foo = “blue”;

4. string bar = foo;

5. foo = “green”;

6. System.out.printIn(bar);

7. }

8. }

What is the result?    (该题为必答题)

标记为待复查 
(2) 分数

An exception is thrown

 

The program prints “blue”

 

The program prints “null”

 

The code will not compile.

 

 

 

34.

Exhibit:

1. class A {

2. public String toString () {

3. return “4”;

4. }

5. }

6. class B extends A {

7. 8. public String toString () {

8. return super.toString() + “3”;

9. }

10. }

11. public class Test {

12. public static void main(String[]args) {

13. System.out.printIn(new B());

14. }

15. }What is the result?    (该题为必答题)

标记为待复查 
(2) 分数

Compilation succeeds and 4 is printed.

 

An error on line 9 causes compilation to fail.

 

Compilation succeeds and 43 is printed.

 

An error on line 14 causes compilation to fail.

 

 

 

35.

Given:

11. public static void main(String[] args) {

12. Object obj = new int[] { 1, 2, 3 };

13. int[] someArray = (int[])obj;

14. for (int i : someArray) System.out.print(i + " ");

15. }

What is the result?    (该题为必答题)

标记为待复查 
(2) 分数

Compilation fails because of an error in line 12.

 

Compilation fails because of an error in line 13.

 

Compilation fails because of an error in line 14.

 

 

 

多项选择

 

36.

Given:

11. public class Commander {

12. public static void main(String[] args) {

13. String myProp = /* insert code here */

14. System.out.println(myProp);

15. }

16. }

and the command line:

java -Dprop.custom=gobstopper Commander

Which two, placed on line 13, will produce the output gobstopper? (Choose two.)    (该题为必答题)

标记为待复查 
(2) 分数

System.load("prop.custom");

 

System.property("prop.custom");

 

System.getenv("prop.custom");

 

System.getProperties().getProperty("prop.custom");

 

System.getProperty("prop.custom");

 

 

 

37.

Which of the following statements will cause a compiler error.    (该题为必答题)

标记为待复查 
(2) 分数

float F=4096.0;

 

byte B=4096;

 

double D=4096.0;

 

char C=4096

 

 

 

38.

Which of the following code fragments are legal Java code?    (该题为必答题)

标记为待复查 
(2) 分数

String A="abcdefg"; A-="cde";

 

Integer J=new Integer(27); J--;

 

String A="abcdefg"; A+="cde";

 

Integer J=new Integer(27); J-=7;

 

 

 

39.

[Check all correct answers]

You are writing a java class in a file named "MyClass.java", this class must be accessible by all classes in a large project. Which of the following would be correct class declarations?    (该题为必答题)

标记为待复查 
(2) 分数

private class MyClass extends Object

 

public class MyClass

 

class myclass extends Object

 

public class MyClass extends Object

 

 

 

40.

Which of the following Java statements correctly declare an array of int primitives?    (该题为必答题)

标记为待复查 
(2) 分数

int scores[];

 

int scores={0,0,0,0};

 

int[] scores;

 

 

 

 

多项选择

 

41.

Which of the following statements will cause a compiler error    (该题为必答题)

标记为待复查 
(2) 分数

float F=4096.0;

 

double D=4096.0;

 

char C=4096;

 

byte B=4096;

 

 

 

42.

Given the following code for the Demo class:

public class Demo extends Base

{

private int count;

public Demo()

{

System.out.println("A Demo object has been created");

}

protected void addOne() {count++; }

}

Which of the following statements about the "count" variable is correct?    (该题为必答题)

标记为待复查 
(2) 分数

When a new Demo object is created, the value of count is zero.

 

When a new Demo object is created, the value of count is undefined.

 

An object of the Base class can have methods which modify the count variable.

 

The only way the count variable can be modified out this class is bycalling the addOne method.

 

 

 

43.

Pick the keyword(s) which can NOT be used as modifiers in declaration of a method in a Java class.    (该题为必答题)

标记为待复查 
(2) 分数

static

 

private

 

generic

 

synchronized

 

protected

 

friend

 

 

 

44.

Once created, some Java objects are "immutable", meaning they can not have their contents changed. Which of the following classed produce immutable objects?    (该题为必答题)

标记为待复查 
(2) 分数

java.lang.Double

 

java.lang.StringBuffer

 

java.lang.Boolean

 

java.lang.Math

 

 

 

45.

You are writing a java class in a file named "MyClass.java", this class must be accessible by all classes in a large project. Which of the following would be correct class declarations?    (该题为必答题)

标记为待复查 
(2) 分数

private class MyClass extends Object

 

public class MyClass

 

class myclass extends Object

 

public class MyClass extends Object

 

 

 

46.

Which of the following lines of code will compile without error    (该题为必答题)

标记为待复查 
(2) 分数

int i=0; if(i) { System.out.println("Hello"); }

 

int i=1;int j = 2; if(i ==1 &| j==2) System.out.println("OK");

 

boolean b = true; boolean b2 = true; if(b==b2){ System.out.println("So true"); } }

 

int i=1;int j = 2; if(i ==1|| j==2) System.out.println("OK");

 

 

 

47.

Which of the following are legal identifiers    (该题为必答题)

标记为待复查 
(2) 分数

_whatavariable

 

_3_

 

2variable

 

#myvar

 

variable2

 

$anothervar

 

 

 

48.

Which of the following are javakeywords    (该题为必答题)

标记为待复查 
(2) 分数

false

 

case

 

while

 

goto

 

if

 

 

 

49.

Which of the following will compile without

 error    (该题为必答题)

标记为待复查 
(2) 分数

package MyPackage; import java.awt.*; class MyClass{}

 

import java.awt.*; package Mypackage; class Myclass {}

 

/*This is a comment */ package MyPackage; import java.awt.*; class MyClass{}

 

 

 

50.

Given:

11. class ClassA {}

12. class ClassB extends ClassA {}

13. class ClassC extends ClassA {}

and:

21. ClassA p0 = new ClassA();

22. ClassB p1 = new ClassB();

23. ClassC p2 = new ClassC();

24. ClassA p3 = new ClassB();

25. ClassA p4 = new ClassC();

Which three are valid? (Choose three.)    (该题为必答题)

标记为待复查 
(2) 分数

p2 = (ClassC)p4;

 

p1 = p2;

 

p1 = (ClassB)p3;

 

p0 = p1;

 

p2 = (ClassC)p1;

 

p2 = p4;

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值