Core Java Question Bank 2 ACTS
Core Java Question Bank 2 ACTS
94
same directory Q. No. 7
2. When the applet class file is in the same The switch() construct is used to make a choice
21
directory based upon ___________.
3. When we need to get the parameters of 1. char value
59
the applet 2. An int value
4. None of the above 3. A String value
07
Correct Answer: 2 1 4. None of the above
Correct Answer: 1
80
Q. No. 3
Given the following code, which of the following Q. No. 8
option if inserted after the
.in
String s1 = "Sun";
System.out.println(s1.substring(5));
ra
interface Remote{ }
public void test(); }
ar
} What is output?
public class Moodle{
ith
1. -1
public static void main(String argv[]){ 2. 0
Moodle m = new Moodle();
w
3. StringIndexOutOfBoundsException
} 4. ArrayIndexOutOfBoundsException
de
}
} Q. No. 9
1. Remote r = new Remote(){ public void Which of the following modifiers can be applied
test(){} }; to a constructor?
2. Remote remote = new Remote(); 1. Private Constructors can have access
3. test(); 2. abstract modifiers such as public, private,
4. this.main(); 3. volatile protected, or no modifier at all
Correct Answer: 1 4. All of the above
Correct Answer: 1
Q. No. 4
Which of the following initializes boolean Q. No. 10
primitive? Which of the following class is thread safe?
1. Boolean flag=true; 1. ArrayList
2. boolean flag=true; 2. HashMap
3. boolean flag=TRUE; 3. Hashtable
4. Boolean flag=TRUE; 4. HashSet
Correct Answer: 2 Correct Answer: 3
Page 1 of 2
ACTS, Pune
Q. No. 11 Q. No. 16
class DAC { Which type of variables cannot be serialized?
public static void main(String[] s) { 1. transient
String s1 = "A", s2 = " B ", s3 = "C"; 2. final
3. private
s2.trim(); s3.concat("D"); 4. None of these
System.out.print(s1 + s2 + s3); Correct Answer: 1
}
} Q. No. 17
What is the result of attempting to There are two computers are connected to
compile and run the program? internet, one computer is trying to open a socket
connection to read the home page of another
1. Prints: ABC
computer, what are the possible exceptions
2. Prints: A B C thrown
3. Prints: ABCD while connection and reading InputStream?
4. Prints: ABDC 1. IOException
Correct Answer: 2 2. MalformedURLException
94
3. Both 1 and 2
Q. No. 12 4. None of the above
21
class A {A(int i) {}} // 1 Correct Answer: 3
class B extends A {} // 2
59
Which of the following statement is true? Q. No. 18
1. The compiler attempts to create a class CDAC {
07
default constructor for class A public static void main (String[] args) {
2. No any error, everything will work fine StringBuffer sb1 = new
80
3. Compile-time error at 1 StringBuffer("ABC");
4. Compile-time error at 2 StringBuffer sb2 = new
Correct Answer: 4 StringBuffer("ABC");
.in
System.out.print(“Prints:”+(sb1==sb2)+",
Q. No. 13 "+sb1.equals(sb2));
ys
Page 2 of 2