单选题
期中小测错题
1. Which specifier essentially declares a variable a global variable?
A. protected
B. static
C. final
D. default
2. What code may be filled in the blank without causing syntax or runtime errors ?
public class Test {
   java.util.Date date;
   public static void main(String[] args) {
     Test test = new Test();
     System.out.println(_________________);
   }
 }
A. test.date
B. date
C. test.date.toString()
D. date.toString()
3. 关于被保护访问控制符protected修饰的成员变量,以下说法正确的是:
A. 可以被三种类所引用:该类自身、与它在同一个包中的其他类、在其他包中的该类的子类
B. 可以被两种类访问和引用:该类本身、该类的所有子类
C. 只能被该类自身所访问和修改
D. 只能被同一个包中的类访问
4. Which of the following statements are not true ?
A. A default constructor is provided automatically if no constructors are explicitly declared in the class
B. At least one constructor must always be defined explicitly
C. The default constructor is a no-arg constructor
D. A default constructor always exist in class
5. What will happen when you attempt to compile and run the following code?
class Base{
 Base(){
         System.out.println("Base");
         }
 }
public class Checket extends Base{
 public static void main(String argv[]){
         Checket c = new Checket();
         super();
         }
Checket(){
         System.out.println("Checket");  
         }       
 }
A. Compile time error
B. Checket followed by Base
C. Base followed by Checket
D. runtime error
6. What is the output of running class C?
class A {
   public A() {
     System.out.println(
       "The default constructor of A is invoked");
   }
 }
class B extends A {
   public B() {
     System.out.println(
       "The default constructor of B is invoked");
   }
 }
public class C  {
   public static void main(String[] args) {
     B b = new B();
   }
 }
A. Nothing displayed
B. "The default constructor of B is invoked"
C. "The default constructor of A is invoked""The default constructor of B is invoked"
D. "The default constructor of B is invoked""The default constructor of A is invoked"










