单项选择题
ClassOne.java: 1. package com.abe.pkg1; 2. public class ClassOne { 3. private char var = ‘a’; 4. char getVar() { return var; } 5. } ClassTest.java: 1. package com.abe.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 fails.
B. Compilation succeeds and no exceptions are thrown.
C. An exception is thrown at line 5 in ClassTest.java.
D. An exception is thrown at line 6 in ClassTest.java.
点击查看答案&解析
相关考题
-
单项选择题
public class Foo { public static void main(String[] args) { try { return; } finally { System.out.println( “Finally” ); } } } What is the result?()
A. Finally
B. Compilation fails.
C. The code runs with no output.
D. An exception is thrown at runtime. -
多项选择题
Whichthreeformpartofcorrectarraydeclarations?()
A. public int a []
B. static int [] a
C. public [] int a
D. private int a [3]
E. private int [3] a []
F. public final int [] a -
单项选择题
public class SwitchTest { public static void main(String[] args) { System.out.println(“value = “ + switchIt(4)); } public static int switchIt(int x) { int j = 1; switch (x) { case 1: j++; case 2: j++; case 3: j++; case 4: j++; case 5: j++; default: j++; } return j + x; } } What is the result?()
A. value = 3
B. value = 4
C. value = 5
D. value = 6
E. value = 7
F. value = 8