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.
正确答案:B
答案解析:有
微信扫一扫手机做题