1  To make a class well encapsulated which of the following must be made private:
A mutators
B instance variables
C constructors
D accessors2  Which of the following statement about a constructor is false:
A A constructor can initialize the instance variables of any object only once
B A constructor can return a value
C A default constructor will be if the class has no constructor
D A constructor can call another constructor of the same class3  Which of the following classes have a composition relationship ?
A Employee and Student
B Project and Manager
C Employee and Person
D Manager and Employee4  Assume that Salesman is a subclass of Employee (both with default constructors). In the code below, Employee reference e is referring to a Salesman object. Which of the statement(s) below attempting to assign e to a Salesman refernce s is/are valid ? Select all. 
Employee e = new Salesman();
Salesman s;
.....  // statement to assign e to s
A s = e;
B s = (Employee) e;
C s = (Salesman) e;5  In the subclass method increment which of the statements below are valid ? (choose all) 
class A {

   private int a;
   int b;
   protected int c;
   public int d;

}
class B extends A { // in the same package (or directory)
   void increment() {
     // statements to be inserted here
   }
}
A a++
B c++
C d++
D b++6  Assume that CAccount and SAccount are subclasses of Account both of which have overridden the deposit() and withdraw() methods. Which of the statement below is true regarding the transfer method? 
public boolean transfer(Account from, Account to, double amount) {
   if (from.withdraw(amount) == true) ) {
          to.deposit(amount);
          return true;
   }
   return false;
}
 
A It will always call the withdraw() and deposit() of Account class
B It will always call the withdraw() and deposit() of one of the subclasses of Account
C The actual method called cannot be determined at compile-time as it depends on the type of objects being passed
D It will always call the deposit of Account and withdraw() of CAccount7  What class relationship(s) ("is-a", "has-a") can be inferred from the class defintion below ? 
public class A extends B
{
C c;
D d;
...
A A "is-a" B
 B B "has-a" D
 C A "has-a" D
D A "has-a" C8  Given the array declaration below the first and last elements are (respectively) 
   double[] fall = new double[12];
 
A fall[0],fall[12]
B fall[1],fall[11]
C fall[0],fall[11]
D fall[1],fall[12]9  Answer true or false: 
   A class that is declared abstract need not have abstract methods.
A true
B false10  Select the true statements from the following (you can choose more that one option).
A Two distinct objects may have identitical values
B Java provides a number of predefined classes
C A new instance can be constructed with operator new
D We can create one or more instances of a class11  Assume that Salesman and Clerk are subclasses of Employee (both with default constructors). Which of the statement below will compile correctly and run without errors (no run-time error) ? 
Employee e1 = new Salesman();
Employee e2 = new Clerk();
Clerk c;
.....  // statement to assign something to c 
A c = (Clerk) e1;
B c = e1;
C c = (Clerk)e2;
D c = e2;12  A method that modifies a state of an object is called a :
A mutator
B static method
C accessor
D constructor13  Which of the following methods will be legal in the subclass ? 
import java.io.*;
public class A {
   public double method1(double x, double y) { return 1.0;  }
}
class B extends A {
   //subclass method to be placed after this line
        
}
 
A public int method1(double x, double y, double z) { ... }
B public int method1(double x, double y) { ... }
C public double method1(double x, double y) { ... }
D public double method1(int x, int y) { .... }14  Which of the following are valid method headers ?
A public static int[] meth(int x)
B public static int meth(int x)
C public static int meth(int[] x)
D public static int[] meth(int[] x)15  An abstract method must have the modifier ________________ 
Enter your response below:16  Which of the statement(s) below attempting to override method1() in subclass B is valid ? 
class A {
   void method1(int amount) {   }
}
class B extends A {
   // method1 to be overridden here         }A void method1(int amount) { }
B protected void method1(int amount) { }
C private void method1(int amount) { }
D public void method1(int amount) { }17  Any instance of a Java class may use methods of the class
A Stack
B Applet
C Object
D String18  Answer true or false 
   when applied to a method, static means that the method
   can be called without creating instances of the class
A true
B false19  Answer true or false: 
   A class that has abstract methods must be declared abstract explicitly using abstract modifier.
A true
B false20  Which of the following constructor cannot exist together in the same class with the the constructor 
      public Account(String accountName, double amount) {  ...  }A public Account(String accountName) { ... }
B public Account(double amount, String accountName) { ... }
C public Account(String ID, double amount) { ... }
D public Account(double amount) { ... }