ot throw exceptions not checked in the base class
Question 9)
Which of the following statements are true
1) The automatic garbage collection of the JVM prevents programs from ever running outof 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.
Question 10)
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
Question 11)
You need to read in the lines of a large text file containing tens of megabytes of data. Which of the following would be most suitable for reading in such a file
1) new FileInputStream(“file.name”)
2) new InputStreamReader(new FileInputStream(“file.name”))
3) new BufferedReader(new InputStreamReader(new FileInputStream(“file.name”)));
4) new RandomAccessFile raf=new RandomAccessFile(“myfile.txt”,”+rw”);
Question 12)
Which of the following statements are true
1) Constructors cannot have a visibility modifier
2) Constructors are not inherited
3) Constructors can only have a primitive return type
4) Constructors can be marked public and protected, but not private
Question 13)
Which statement is true
1)An anonymous inner class may be declared as final.
2)An anonymous inner class can be declared as private.
3)An anonymous inner class can implement multiple interfaces .
4)An anonymous inner class can access final variables in any enclosing scope.
5)Construction of an instance of a static inner class requires an instance of the enclosing outer class.
Question 14)
public class Foo{
public static void main(String sgf[]){
StringBuffer a = new StringBuffer(“A”);
StringBuffer b = new StringBuffer(“B”);
operate(a,b);
System.out.println(a+”,”+b); }
static void operate(StringBuffer x,StringBuffer y){
x.append(y);
y=x; }}
What is the result
1)The code compiles and prints “A.B”.
2)The code compiles and prints “A.A”.
3)The code compiles and prints “B.B”.
4)The code compiles and prints “AB.B”.
5)The code compiles and prints “AB.AB”.
Question 15)
Which of the following thread state transitions are valid
1) From ready to running.
2) From running to ready.
3) From running to waiting.
4) From waiting to running.
5) From waiting to ready.
6) From ready to waiting.
Question 16)
What is the result of attempting to compile and run the following program
public class Test {
private int i = j;
private int j = 10;
public static void main(String args[]) {
System.out.println((new Test()).i);
}
}
1) Compiler error complaining about access restriction of private variables of Test.
2) Compiler error complaining about forward referencing.
3) No error - The output is 0;
4) No error - The o