0% found this document useful (0 votes)
27 views

Core Java Question Bank 2 ACTS

Uploaded by

White Devil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Core Java Question Bank 2 ACTS

Uploaded by

White Devil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ACTS, Pune

Question Paper J2SE- Core Java


Q. No. 1 Q. No. 5
Which of the following statement is true? Which of the following is not correct?
1. An object will be garbage collected 1. int a [][] = new int [20][20];
when it becomes unreachable 2. int [] a [] = new int [20][];
2. An object will be garbage collected if it 3. int [][] a = new int [10][];
has null assigned to it 4. int [][] a = new int [][10];
3. The finalize method will be run before Correct Answer: 4
an object is garbage collected
4. Garbage collection assures that a Q. No. 6
program will never run out of memory instanceof operator can be used with ________.
Correct Answer: 3 1 1. Arrays
2. Final Class
Q. No. 2 3. Classes
The command ‘codebase’ is used in applets 4. All of the above
_____________. Correct Answer: 3 4
1. When the applet class file is not in the

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

public class CDAC{


comment //here will allow the code to compile public static void main(String a[]){
without error?
ys

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

public void go(){ Correct Answer: 3


//here
co

}
} 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

Inner classes can not declare______ variables }


ra

1. static The delete() method of }


2. protected java.io.File is used to What is the result of attempting to compile and
ar

3. final delete a file or directory . It run the program?


4. transient returns true/False . If the 1. Prints: false, true
ith

Correct Answer: 1 file is a directory, it must be 2. Prints: false, false


3. Prints: true, false
w

empty in order to be deleted


Q. No. 14 4. Prints: true, true
de

Please select a true statement about delete() Correct Answer: 2


method of java.io.File.
co

1. It can delete a file Q. No. 19


2. It can delete an empty directory How many methods are defined in the
3. Both of the above Cloneable interface?
4. Neither of the above 1. None
Correct Answer: 3 2. One
3. Two
Q. No. 15 4. None of the above
• Entries are organized as key/value pairs Correct Answer: 1
• Duplicate entries replace old entries Q. No. 20
Which interface of the java.util package offer the The term "instance variable" is another name for
specified behaviour? ___________.
1. List 1. Static field
2. Map 2. Non-static field
3. Set 3. Local variable
4. None of the above 4. None of the above
Correct Answer: 2 Correct Answer: 2

Page 2 of 2

You might also like