ACTS, Pune: Question Paper J2SE-Core Java
ACTS, Pune: Question Paper J2SE-Core Java
ACTS, Pune: Question Paper J2SE-Core Java
Q. No. 1 Which of the following statement is true? 1. An object will be garbage collected when it becomes unreachable 2. An object will be garbage collected if it has null assigned to it 3. The finalize method will be run before an object is garbage collected 4. Garbage collection assures that a program will never run out of memory Correct Answer: 3 Q. No. 2 The command codebase is used in applets _____________. 1. When the applet class file is not in the same directory 2. When the applet class file is in the same directory 3. When we need to get the parameters of the applet 4. None of the above Correct Answer: 2 Q. No. 3 Given the following code, which of the following option if inserted after the comment //here will allow the code to compile without error? interface Remote{ public void test(); } public class Moodle{ public static void main(String argv[]){ Moodle m = new Moodle(); } public void go(){ //here } } 1. Remote r = new Remote(){ public void test(){} }; 2. Remote remote = new Remote(); 3. test(); 4. this.main(); Correct Answer: 1 Q. No. 4 Which of the following initializes boolean primitive? 1. Boolean flag=true; 2. boolean flag=true; 3. boolean flag=TRUE; 4. Boolean flag=TRUE; Correct Answer: 2 Q. No. 5 Which of the following is not correct? 1. int a [][] = new int [20][20]; 2. int [] a [] = new int [20][]; 3. int [][] a = new int [10][]; 4. int [][] a = new int [][10]; Correct Answer: 4 Q. No. 6 instanceof operator can be used with ________. 1. Arrays 2. Final Class 3. Classes 4. All of the above Correct Answer: 3 Q. No. 7 The switch() construct is used to make a choice based upon ___________. 1. char value 2. An int value 3. A String value 4. None of the above Correct Answer: 1 Q. No. 8 public class CDAC{ public static void main(String a[]){ String s1 = "Sun"; System.out.println(s1.substring(5)); } } What is output? 1. -1 2. 0 3. StringIndexOutOfBoundsException 4. ArrayIndexOutOfBoundsException Correct Answer: 3 Q. No. 9 Which of the following modifiers can be applied to a constructor? 1. Private 2. abstract 3. volatile 4. All of the above Correct Answer: 1 Q. No. 10 Which of the following class is thread safe? 1. ArrayList 2. HashMap 3. Hashtable 4. HashSet Correct Answer: 3 Page 1 of 2
ACTS, Pune
Q. No. 11
class DAC { public static void main(String[] s) { String s1 = "A", s2 = " B ", s3 = "C"; s2.trim(); s3.concat("D"); System.out.print(s1 + s2 + s3); } } What is the result of attempting to compile and run the program? 1. Prints: ABC 2. Prints: A B C 3. Prints: ABCD 4. Prints: ABDC
Correct Answer: 2 Q. No. 12 class A {A(int i) {}} // 1 class B extends A {} // 2 Which of the following statement is true? 1. The compiler attempts to create a default constructor for class A 2. No any error, everything will work fine 3. Compile-time error at 1 4. Compile-time error at 2 Correct Answer: 4 Q. No. 13 Inner classes can not declare______ variables 1. static 2. protected 3. final 4. transient Correct Answer: 1 Q. No. 14 Please select a true statement about delete() method of java.io.File. 1. It can delete a file 2. It can delete an empty directory 3. Both of the above 4. Neither of the above Correct Answer: 3 Q. No. 15 Entries are organized as key/value pairs Duplicate entries replace old entries Which interface of the java.util package offer the specified behaviour? 1. List 2. Map 3. Set 4. None of the above Correct Answer: 2
Q. No. 16 Which type of variables cannot be serialized? 1. transient 2. final 3. private 4. None of these Correct Answer: 1 Q. No. 17 There are two computers are connected to internet, one computer is trying to open a socket connection to read the home page of another computer, what are the possible exceptions thrown while connection and reading InputStream? 1. IOException 2. MalformedURLException 3. Both 1 and 2 4. None of the above Correct Answer: 3 Q. No. 18 class CDAC { public static void main (String[] args) { StringBuffer sb1 = new StringBuffer("ABC"); StringBuffer sb2 = new StringBuffer("ABC"); System.out.print(Prints:+(sb1==sb2)+", "+sb1.equals(sb2)); } } What is the result of attempting to compile and run the program? 1. Prints: false, true 2. Prints: false, false 3. Prints: true, false 4. Prints: true, true Correct Answer: 2 Q. No. 19 How many methods are defined in the Cloneable interface? 1. None 2. One 3. Two 4. None of the above Correct Answer: 1 Q. No. 20 The term "instance variable" is another name for ___________. 1. Static field 2. Non-static field 3. Local variable 4. None of the above Correct Answer: 2
Page 2 of 2