Question 28)
You are given a class hierarchy with an instance of the class Dog. The class Dog is a child of mammal and the class Mammal is a child of the class Vertebrate. The class Vertebrate has a method called move which prints out the string "move". The class mammal overrides this method and prints out the string "walks". The class Dog overrides this method and prints out the string "walks on paws". Given an instance of the class Dog,. how can you access the ancestor method move in Vertebrate so it prints out the string "move";
1) d.super().super().move();
2) d.parent().parent().move();
3) d.move();
4) none of the above;
Answer to Question 28)
--------------------------------------------------------------------------------
Question 29)
Which of the following most closely describes the process of overriding?
1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy
2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy
3) A method with the same name but different parameters gives multiple uses for the same method name
4) A class is prevented from accessing methods in its immediate ancestor
Answer to Question 29)
--------------------------------------------------------------------------------
Question 30)
Which of the following statements are true?
1) The % is used to calculate a percentage thus: 10 % 20=50
2) The / operator is used to divide one value by another
3) The # symbol may not be used as the first character of a variable
4) The $ symbol may not be used as the first character of a variable
Answer to Question 30)
--------------------------------------------------------------------------------
Question 31)
Which of the following statements are true?
1) The default layout manager for an Applet is FlowLayout
2) The default layout manager for a Frame is FlowLayout
3) A layout manager must be assigned to an Applet before the setSize method is called
4) The FlowLayout manager attempts to honor the preferred size of any components
Answer to Question 31)
--------------------------------------------------------------------------------
Question 32)
Which of the following statements are true about a variable created with the static modifier?
1) Once assigned the value of a static variable may not be altered
2) A static variable created in a method will keep the same value between calls
3) Only one instance of a static variable will exist for any amount of class instances
4) The static modifier can only be applied to a primitive value
Answer to Question 32)
--------------------------------------------------------------------------------
Question 33)
Which of the following statements are true?
1) Java uses a system called UTF for I/O to support international character sets
2) The RandomAccessFile is the most suitable class for supporting international character sets
3) An instance of FileInputStream may not be chained to an instance of FileOutputStream
4) File I/O activities requires use of Exception handling
Answer to Question 33)
--------------------------------------------------------------------------------
Question 34)
What will happen when you attempt to compile and run the following code?
import java.io.*;
class ExBase{
abstract public void martley(){
}
}
public class MyEx extends ExBase{
public static void main(String argv[]){
DataInputStream fi = new DataInputStream(System.in);
try{
fi.readChar();
}catch(IOException e){
System.exit(0);
}
finally {System.out.println("Doing finally");}
}
}
1) Compile time error
2) It will run, wait for a key press and then exit
3) It will run, wait for a keypress, print "Doing finally" then exit
4) At run and immediately exit
Answer to Question 34)