Section 3:
Java Implementation of Object-Oriented Concepts
( click here for the exam objectives )
 
Question 3-1
Which of the given code fragments will compile without errors ?
Select all correct answers :
a. float f=3.5;
b. double d=3.5;
c. int i=10;
d. int e,f=10;
e. char c = "C";
Answer

Question 3-2
What will be the result of compiling and running the following code ?
abstract class Employee {
    String name;    
    public abstract float calcIncome();
}

class Manager extends Employee {
    public void hire(String who) {
        System.out.println( who + " hired by " + name );
    }    
    
    public void fire(String who) {
        System.out.println( who + " fired by " + name );
    }
}
 
public class ManagerCheck {
    public static void main(String args[]) {
        Manager me = new Manager();
        me.hire("newbie");
        me.fire("nobody");
    }
}
Select the correct answer :
a. who hired by name and who fired by name
b. newbie hired by name and nobody fired by name
c. newbie hired by null and nobody fired by null
d. Compilations fails
Answer

Question 3-3
According to the UML diagram - what is the correct Java representation of Animal and Cat ?
Select the correct answer :
a. class Cat implements Animal { }
b. class Animal extends Cat { }
c. class Animal implements Cat { }
d. class Cat extends Animal { }
e. UML diagram is invalid
Answer

Question 3-4
Methods defined in a java interface are public and abstract by default.
Select the correct answer :
a. The statement is true.
b. The statement is false.
Answer

Question 3-5
Which of the following statements about abstract classes in java are true ?
Select all correct answers :
a. A class must be declared abstract if one or more methods are abstract.
b. A class can be declared abstract if one or more methods are abstract.
c. A class can be declared abstract without abstract methods.
d. An abstract class cannot be instanciated.
Answer


How do you rate this mock exam ?
very easy easy medium advanced hard
Feel free to use the feedback formular to give us detailed comments or suggestions .

 
 
 
 
last modified : 6/21/2012 - 20:38