Question 46)
Which of the following statements are true?
1) A method cannot be overloaded to be less public in a child class
2) To be overridden a method must have the same name and parameter types
3) To be overridden a method must have the same name, parameter and return types
4) An overridden method must have the same name, parameter names and parameter types
Answer to Question 46)
--------------------------------------------------------------------------------
Question 47)
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");
}
}
1) Compile time error
2) Checket followed by Base
3) Base followed by Checket
4) runtime error
Answer to Question 47)
--------------------------------------------------------------------------------
Question 48)
Which of the following statements are true?
1) Static methods cannot be overriden to be non static
2) Static methods cannot be declared as private
3) Private methods cannot be overloaded
4) An overloaded method cannot throw exceptions not checked in the base class
Answer to Question 48)
--------------------------------------------------------------------------------
Question 49)
Which of the following statements are true?
1) The automatic garbage collection of the JVM prevents programs from ever running out of memory
2) A program can suggest that garbage collection be performed but not force it
3) Garbage collection is platform independent
4) An object becomes eligible for garbage collection when all references denoting it are set to null.
Answer to Question 49)
--------------------------------------------------------------------------------
Question 50)
Given the following code
public class Sytch{
int x=2000;
public static void main(String argv[]){
System.out.println("Ms "+argv[1]+"Please pay $"+x);
}
}
What will happen if you attempt to compile and run this code with the command line
java Sytch Jones Diggle
1) Compilation and output of Ms Diggle Please pay $2000
2) Compile time error
3) Compilation and output of Ms Jones Please pay $2000
4) Compilation but runtime error
Answer to Question 50)
--------------------------------------------------------------------------------
Question 51)
What will happen when you attempt to compile and run the following code
class Base{
protected int i = 99;
}
public class Ab{
private int i=1;
public static void main(String argv[]){
Ab a = new Ab();
a.hallow();
}
abstract void hallow(){
System.out.println("Claines "+i);
}
}
1) Compile time error
2) Compilation and output of Claines 99
3) Compilation and output of Claines 1
4) Compilation and not output at runtime
Answer to Question 51)
--------------------------------------------------------------------------------
Question 52)
You have been asked to create a scheduling system for a hotel and catering organsiation.
You have been given the following information and asked to create a set of classes to represent it.
On the catering side of the organsiation they have
Head Chefs
Chefs
Apprentice Chefs
The system needs to store an employeeid, salary and the holiday entitlement
How would you best represent this information in Javae been given the following information and asked to create a set of classes to represent it.
On the catering side of the organsiation they have
Head Chefs
Chefs
Apprentice Chefs
The system needs to store an employeeid, salary and the holiday entitlement
How would you best represent this information in Java
1) Create classes for Head Chef, Chef, Apprentice Chef and store the other values in fields
2) Create an employee class and derive sub classes for Head Chef, Chef, Apprentice Chef and store the other values in fields.
3) Create and employee class with fields for Job title and fields for the other values.
4) Create classes for all of the items mentioned and create a container class to represent employees
Answer to Question 52)