black

SCJP程序员认证考试

登录

单项选择题

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.

相关考题

多项选择题 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?()

单项选择题 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?()

单项选择题 Whichstatementaboutstaticinnerclassesistrue?()

All Rights Reserved 版权所有©建筑考试题库(jzkao.com)

备案号:湘ICP备2020024380号-3