| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 957 人关注过本帖
标题:68--93题
只看楼主 加入收藏
kingarden
Rank: 2
等 级:论坛游民
威 望:1
帖 子:517
专家分:40
注 册:2004-12-8
收藏
 问题点数:0 回复次数:0 
68--93题

68. Click the exhibit button:

1. class A { 2. public int getNumber(int a) { 3. return a + 1; 4. } 5. } 6. 7. class B extends A { 8. public int getNumber (int a) { 9. return a + 2 10. } 11. 12. public static void main (String args[]) { 13. A a = new B(); 14. System.out.printIn(a.getNumber(0)); 15. } 16. }

What is the result?

A. Compilation succeeds and 1 is printed. B. Compilation succeeds and 2 is printed. C. An error at line 8 causes compilation to fail. D. An error at line 13 causes compilation to fail. E. An error at line 14 causes compilation to fail.

69. Given:

1. class BaseClass{ 2. private float x= 1.0f; 3. protected void setVar (float f) {x = f;} 4. } 5. class SubClass exyends BaseClass { 6. private float x = 2.0f; 7. //insert code here 8. }

Which two are valid examples of method overriding? (Choose Two)

A. void setVar(float f) {x = f;} B. public void setVar(int f) {x = f;} C. public void setVar(float f) {x = f;} D. public double setVar(float f) {x = f;} E. public final void setVar(float f) {x = f;} F. protected float setVar() {x=3.0f; return 3.0f; }

70. Which statement about static inner classes is true?

A. An anonymous class can be declared as static. B. A static inner class cannot be a static member of the outer class C. A static inner class does not require an instance of the enclosing class. D. Instance members of a static inner class can be referenced using the class name of the static inner class.

71. Click the exhibit button:

1. class A { 2. public byte getNumber () { 3. return 1; 4. } 5. } 6. 7. class B extends A { 8. public short getNumber() { 9. return 2; 10. } 11. 12. public static void main (String args[]) { 13. B b = new B (); 14. System.out.printIn(b.getNumber()) 15. } 16. }

What is the result?

A. Compilation succeeds and 1 is printed. B. Compilation succeeds and 2 is printed. C. An error at line 8 causes compilation to fail. D. An error at line 14 causes compilation to fail. E. Compilation succeeds but an exception is thrown at line 14.

72. Given:

AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument.

Which two construct an anonymous inner class? (Choose Two)

A. AnAdapter1 aa=new AnAdapter1(){} B. AnAdapter0 aa=new AnAdapter0(){} C. AnAdapter0 aa=new AnAdapter0(5){} D. AnAdapter1 aa=new AnAdapter1(5){} E. AnInterface a1=new AnInterface(5){}

73. Which two statements are true? (Choose Two)

A. An inner class may be declared as static B. An anonymous inner class can be declared as public. C. An anonymous inner class can be declared as private. D. An anonymous inner class can extend an abstract class. E. An anonymous inner class can be declared as protected.

74. Click the exhibit button:

1. public class Mycircle { 2. public double radius; 3. public double diameter; 4. 5. public void setRadius(double radius) 6. this.radius = radius; 7. this.diameter= radius * 2; 8. } 9. 10. public double getRadius() { 11. return radius; 12. } 13. }

Which statement is true?

A. The Mycircle class is fully encapsulated. B. The diameter of a given MyCircle is guaranteed to be twice its radius. C. Lines 6 and 7 should be in a synchronized block to ensure encapsulation. D. The radius of a MyCircle object can be set without affecting its diameter.

75. You want to limit access to a method of a public class to members of the same class. Which access modifier accomplishes this objective?

A. Public B. Private C. Protected D. Transient E. No access modifier is required

76. Click the exhibit button.

ClassOne.java 1. package com.abc.pkg1; 2. public class ClassOne { 3. private char var = ‘a’; 4. char getVar() {return var;} 5. } ClassTest.java 1. package com.abc.pkg2; 2. import com.abc.pkg1.ClassOne; 3. public class ClassTest extends ClassOne { 4. public static void main(String[]args) { 5. char a = new ClassOne().getVar(); 6. char b = new ClassTest().getVar(); 7. } 8. }

What is the result?

A. Compilation will fail. B. Compilation succeeds and no exceptions are thrown. C. Compilation succeeds but an exception is thrown at line 5 in ClassTest.java. D. Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.

77. Given:

1. public class ArrayTest { 2. public static void main (String[]args) { 3. float f1[], f2[]; 4. f1 = new float [10]; 5. f2 = f1; 6. System.out.printIn (“f2[0]=” + f2[0]); 7. } 8. }

What is the result?

A. It prints f2[0] = 0.0. B. It prints f2[0] = NaN. C. An error at line 5 causes compile to fail. D. An error at line 6 causes compile to fail. E. An error at line 6 causes an exception at runtime.

78. Which two statements are true regarding the creation of a default constructor? (Choose Two)

A. The default constructor initializes method variables. B. The compiler always creates a default constructor for every class. C. The default constructor invokes the no-parameter constructor of the superclass. D. The default constructor initializes the instance variables declared in the class. E. When a class has only constructors with parameters, the compiler does not create a default constructor.

79. Click the exhibit button:

1. class super { 2. public int getLength() {return 4;} 3. } 4. 5. public class Sub extends Super { 6. public long getLength() {return 5;} 7. 8. public static void main (String[]args) { 9. super sooper = new Super (); 10. Sub sub = new Sub(); 11. System.out.printIn( 12. sooper.getLength()+ “,” + sub.getLength() }; 13. } 14. }

What is the output?

A. 4, 4 B. 4, 5 C. 5, 4 D. 5, 5 E. the code will not compile

80. Given:

1. public abstract class Test { 2. public abstract void methodA(); 3. 4. public abstract void methodB() 5. { 6. System.out.printIn(“Hello”); 7. } 8. }

Which three changes (made independently) allow the code to compile? (Choose Three) A. Add a method body to methodA. B. Replace lines 5-7 with a semicolon (“.”). C. Remove the abstract qualifier from the declaration of Test. D. Remove the abstract qualifier from the declaration of methodB. E. Remove the abstract qualifier from the declaration of methodA. F. Remove methodB in its entirely and change class o interface in line 1.

81. Which determines if “prefs” is a directory and exists on the file system?

A.Boolean exists=Directory.exists (“prefs”); B.Boolean exists=(new File(“prefs”)).isDir(); C.Boolean exists=(new Directory(“prefs”)).exists(); D.Boolean exists=(new File(“prefs”)).isDirectory(); E.Boolean exists=true; Try{ Directory d = new Directory(“prefs”); } catch (FileNotFoundException e) { exists = false; }

82. Which two create an InputStream and open file the “file.txt” for reading? (Choose Two)

A. InputStream in=new FileReader(“file.txt”); B. InputStream in=new FileInputStream(“file.txt”); C. InputStream in=new InputStreamFileReader (“file.txt”, “read”); D. FileInputStream in=new FileReader(new File(“file.txt”)); E. FileInputStream in=new FileInputStream(new File(“file.txt”));

83. Which two construct an OutputSream that appends to the file “file.txt”? (Choose Two)

A. OutputStream out=new FileOutputStream(“file.txt”); B. OutputStream out=new FileOutputStream(“file.txt”, “append”); C. FileOutputStream out=new FileOutputStream(“file.txt”, true); D. FileOutputStream out=new FileOutputStream(new file(“file.txt”)); E. OutputStream out=new FileOutputStream(new File(“file.txt”)true);

84. Which constructs a BufferedInputStream?

A. New BufferedInputStream(“in.txt”); B. New BufferedInputStream(new File(“in.txt”)); C. New BufferedInputStream(new Writer(“in.txt”)); D. New BufferedInputStream(new Writer(“in.txt”)); E. New BufferedInputStream(new InputStream(“in.txt”)); F. New BufferedInputStream(new FileInputStream(“in.txt”));

85. Which is a valid identifier?

A. false B. default C. _object D. a-class

86. Click the exhibit button:

1. package foo; 2. 3. import java.util.Vector; 4. 5. private class MyVector extends Vector { 6. int i = 1; 7. public MyVector() { 8. i = 2; 9. } 10. } 11. 12. public class MyNewVector extends MyVector { 13. public MyNewVector () { 14. i = 4; 15. } 16. public static void main (String args []) { 17. MyVector v = new MyNewVector(); 18. } 19. }

The file MyNewVector.java is shown in the exhibit.

What is the result?

A. Compilation will succeed B. Compilation will fail at line 5 C. Compilation will fail at line 6 D. Compilation will fail at line 14 E. Compilation will fail at line 17

87. Given:

1. public class Test { 2. public static void main (String[]args) { 3. String foo = args[1]; 4. String bar = args[2]; 5. String baz = args[3]; 6. System.out.printIn(“baz = ” + baz); 7. } 8. }

And the output: Baz = 2

Which command line invocation will produce the output?

A. java Test 2222 B. java Test 1 2 3 4 C. java Test 4 2 4 2 D. java Test 4 3 2 1

88. Given:

8. int index = 1; 9. String [] test = new String[3]; 10. String foo = test[index];

What is the result?

A. foo has the value “” B. foo has the value null C. an exception is thrown D. the code will not compile

89. Given:

1. public interface Foo{ 2. int k = 4; 3. }

Which three are equivalent to line 2? (Choose Three)

A.final int k = 4; B.public int k = 4; C.static int k = 4; D.private int k = 4; E.abstract int k = 4; F.volatile int k = 4; G.transient int k = 4; H.protected int k = 4;

90. Given:

1. public class foo { 2. static String s; 3. public static void main (String[]args) { 4. system.out.printIn (“s=” + s); 5. } 6. }

What is the result?

A. The code compiles and “s=” is printed. B. The code compiles and “s=null” is printed. C. The code does not compile because string s is not initialized. D. The code does not compile because string s cannot be referenced. E. The code compiles, but a NullPointerException is thrown when toString is called. 91. Which of the following two are valid declarations of a char? (Choose Two)

A.char ch = “a”; B.char ch = ‘\’ ‘; C.char ch = ‘cafe’; D.char ch = “cafe”; E.char ch = ‘\ucafe’; F.char ch = ‘\u10100’; G.char ch = (char) true;

92. Given:

1. String foo = “blue”; 2. Boolean[]bar = new Boolean [1]; 3. if (bar[0]) { 4. foo = “green”; 5. }

What is the result?

A.foo has the value of “” B.foo has the value of null C.foo has the value of “blue” D.foo has the value of “green” E.an exception is thrown F.the code will not compile

93. Click the exhibit button:

1. public class X { 2. public static void main (String[]args) { 3. String s1 = new String (“true”); 4. Boolean b1 = new Boolean (true); 5. if (s2.equals(b1)) { 6. System.out.printIn(“Equal”); 7. } 8. } 9. }

What is the result?

A. The program runs and prints nothing. B. The program runs and prints “Equal.” C. An error at line 5 causes compilation to fail. D. The program runs but aborts with an exception.

搜索更多相关主题的帖子: public return button causes result 
2004-12-19 15:39
快速回复:68--93题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020685 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved