Java Technologies I
Java Technologies I
Answer Choices
Choice 1: public static int main(char args[])
Choice 2: public static void main(String args[])
Choice 3: public static void MAIN(String args[])
Choice 4: public static void main(String args)
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult
Reference: (Mention name of the book, author, ISBN / Website URL)
(If question
taken from book/
website/etc.)
if(args.length > 1)
System.out.println(i);
if(args.length > 0)
System.out.println(i - 1);
else
System.out.println(i - 2);
}
}
Answer Choices
Choice 1: test
Choice 2: test -1
Choice 3: 0
Choice 4: 1
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
Answer Choices
Choice 1: True
Choice 2: False
Choice 3: Can’t Say
Choice 4: Depends on class definition
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
}
}
Answer Choices
Choice 1: 0
Choice 2: 1
Choice 3: 2
Choice 4: The program does not compile because of statement "i=++i;"
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
Infoway Technologies Pvt. Ltd., Pune Page 2 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: By invoking the free method on the object.
Choice 2: By calling system.gc() method.
Choice 3: By setting all references to the object to new values (say null).
Choice 4: Garbage collection cannot be forced. The programmer cannot force the
JVM to free the memory used by an object.
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: 0
Choice 2: 1
Choice 3: 2
Choice 4: -1
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
Infoway Technologies Pvt. Ltd., Pune Page 3 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: transient
Choice 2: volatile
Choice 3: synchronized
Choice 4: native
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: Collection
Choice 2: Set
Choice 3: List
Choice 4: Map
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
System.out.println(i);
}
}
Answer Choices
Infoway Technologies Pvt. Ltd., Pune Page 5 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Choice 1: 4
Choice 2: 5
Choice 3: 6
Choice 4: 9
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: valueOf
Choice 2: intValue
Choice 3: getInt
Choice 4: getInteger
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: An import statement, if defined, must always be the first non-comment
statement of the file.
Choice 2: private members are accessible to all classes in the same package.
Choice 3: An abstract class can be declared as final.
Choice 4: Local variables cannot be declared as static
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: FlowLayout
Choice 2: BorderLayout
Choice 3: GridLayout
Choice 4: GridBagLayout
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: FlowLayout
Choice 2: GridLayout
Choice 3: BorderLayout
Choice 4: CardLayout
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
class Base{
protected int i = 99;
}
public class Ab{
private int i=1;
Infoway Technologies Pvt. Ltd., Pune Page 7 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
public static void main(String argv[]){
Ab a = new Ab();
a.hallow();
}
}
Answer Choices
Choice 1: Compile time error
Choice 2: Compilation and output of Claines 99
Choice 3: Compilation and output of Claines 1
Choice 4: Compilation and not output at runtime
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: compile error
Choice 2: three components will appear, Label at North, TextField at South and
Button at Center.
Choice 3: only one Button at the Center
Answer Choices
Choice 1: The instanceof operator can be used to determine if a reference is an
instance of a class, but not an interface.
Choice 2: The instanceof operator can be used to determine if a reference is an
instance of a particular primitive wrapper class
Choice 3: The instanceof operator will only determine if a reference is an instance
of a class immediately above in the hierarchy but no further up the
inheritance chain
Choice 4: The instanceof operator can be used to determine if one reference is of
the same class as another reference.
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
do{
if(i>j) continue;
j--;
}while(++i<6);
Answer Choices
Choice 1: i=6 and j=5
Infoway Technologies Pvt. Ltd., Pune Page 9 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Choice 2: i=5 and j=5
Choice 3: i=6 and j=4
Choice 4: i=5 and j=6
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: run
Choice 2: start
Choice 3: stop
Choice 4: yield
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: prints: Value is – 9
Choice 2: prints: Value is – 5
Choice 3: Compilation error
Choice 4: None of these
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
1 class HumptyDumpty
2{
3 void myMethod() {}
4}
5
6 class HankyPanky extends HumptyDumpty
7{
8 void myMethod() {}
9}
Answer Choices
Choice 1: private or nothing(i.e. leaving it as it is) on line 3. Nothing(i.e. leaving it
Infoway Technologies Pvt. Ltd., Pune Page 11 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
as it is) or protected or public on line 8.
Choice 2: public or protected on line 3. private or nothing(i.e. leaving it as it is) on
line 8
Choice 3: nothing(i.e. leaving it as it is) or protected or public on line 3. private or
nothing(i.e. leaving it as it is) on line 8.
Choice 4: None of the above
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
1. class MyClass
2. {
3. void myMethod(int i) {System.out.println("int version");}
4. void myMethod(String s) {System.out.println("String
version");}
5. public static void main(String args[])
6. {
7. MyClass obj = new MyClass();
8. char ch = 'c';
9. obj.myMethod(ch);
10. }
11. }
Answer Choices
Choice 1: Line 4 will not compile as void methods can't be overridden
Choice 2: An exception at line 9.
Choice 3: Line 9 will not compile as there is no version of myMethod which takes a
char as argument
Choice 4: The code compiles and produces output: int version
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Infoway Technologies Pvt. Ltd., Pune Page 12 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
class X
{
Y b = new Y();
X()
{
System.out.print("X");
}
}
class Y
{
Y()
{
System.out.print("Y");
}
}
Z()
{
System.out.print("Z");
}
Answer Choices
Choice 1: Z
Choice 2: YZ
Choice 3: XYZ
Choice 4: ZXYZ
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
Infoway Technologies Pvt. Ltd., Pune Page 13 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
taken from book/
website/etc.)
class Base
{
int i = 99;
}
Answer Choices
Choice 1: Derived.amethod()
-1
Derived.amethod()
Choice 2: Derived.amethod()
99
Infoway Technologies Pvt. Ltd., Pune Page 14 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Derived.amethod()
Choice 3: 99
Derived.amethod()
Choice 4: None of the above
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: The following statement will produce a result of 1. System.out.println( -1
>>>2);
Choice 2: Performing an unsigned left shift (<<<) on a negative number will
always produce a negative number result
Choice 3: The following statement will produce a result of zero,
System.out.println(1 >>1);
Choice 4: All the Java integral types are signed numbers
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: Error: amethod parameter does not match variable
Choice 2: 20 and 40
Choice 3: 10 and 40
Choice 4: 10, and 20
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: FileName.chdir("DirName")
Infoway Technologies Pvt. Ltd., Pune Page 17 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Choice 2: FileName.cd("DirName")
Choice 3: FileName.cwd("DirName")
Choice 4: The File class does not support directly changing the current directory.
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
EqTest(){
String s="Java";
String s2="java";
//place test here {
System.out.println("Equal");
}else
{
System.out.println("Not equal");
}
}
}
Answer Choices
Choice 1: if(s==s2)
Choice 2: if(s.equals(s2))
Choice 3: if(s.equalsIgnoreCase(s2))
Choice 4: if(s.noCaseMatch(s2))
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
}
class Turing extends Thread{
public void run(){
for(int i =0; i < 2; i++){
System.out.println(i);
}
}
Answer Choices
Choice 1: Compilation error due to malformed parameter to go method
Choice 2: Compilation error, class Turing has no start method
Choice 3: Compilation and output of 0 followed by 1
Choice 4: Compilation but runtime error
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: setLayoutManager(new GridLayout());
Choice 2: setLayout(new GridLayout(2,2));
Infoway Technologies Pvt. Ltd., Pune Page 19 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Choice 3: setGridLayout(2,2);
Choice 4: setBorderLayout();
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Holt(String s){
sThreadName = s;
}
public String getThreadName(){
return sThreadName;
}
Answer Choices
Infoway Technologies Pvt. Ltd., Pune Page 20 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Choice 1: Compile time error
Choice 2: Output of first0, second0, first0, second1
Choice 3: Output of first0, first1, second0, second1
Choice 4: Runtime error
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: 6
Choice 2: 0
Choice 3: 1
Choice 4: 7
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: s3=s1 + s2;
Choice 2: s3=s1-s2;
Choice 3: s3=s1 & s2;
Choice 4: s3=s1 && s2
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
Infoway Technologies Pvt. Ltd., Pune Page 21 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
taken from book/
website/etc.)
Answer Choices
Choice 1: mid(2,s);
Choice 2: charAt(2);
Choice 3: s.indexOf('v');
Choice 4: indexOf(s,'v');
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: Bic
Choice 2: ic
Choice 3: icy
Choice 4: error: no method matching substring(int,char)
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: -2
Choice 2: 2.0
Choice 3: -2.0
Choice 4: Nan
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: Yes
Choice 2: No
Choice 3:
Choice 4:
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: Yes
Choice 2: No
Choice 3:
Choice 4:
Correct Answer: Choice 1
Answer Choices
Choice 1: java –Da=b c_d
Choice 2: java -D a=b c_d
Choice 3: javac –Da=b c_d
Choice 4: javac -D a=b c_d
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: Initialization
Choice 2: Runtime
Choice 3: Garbage Collection
Choice 4: None of the above
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: X=42
Choice 2: X=43
Choice 3: X=44
Choice 4: Compilation fails
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: many
Choice 2: a few
Choice 3: Compilation fails.
Choice 4: The output is not predictable.
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Answer Choices
Choice 1: hi hi
Choice 2: hi hi hi
Choice 3: hi, followed by an exception
Choice 4: hi hi, followed by an exception
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)
Q.No.54 Consider the following code in file A: It will give an error at compile D
Sample.java time at line //1
public class Sample implements IInt B: It will give an error at compile
{ time at line //2
public static void main(String[] args){ C: It will give an error at compile
Sample s = new Sample(); //1 time at line //3
int j = s.thevalue; //2 D: It will compile and run without
int k = IInt.thevalue; //3 any problem.
int l = thevalue; //4
}
}
interface IInt
{
int thevalue = 0;
}
What will happen when the above code is
compiled and run?
System.out.println("Claines "+i);
}
}
Q.No.93 Which statements about IO is A: OutputStream is the abstract A
correct? superclass of all classes that
represent an outputstream of
bytes.
B: Subclasses of the class Writer
are used to read character
streams.
C: To write characters to an
outputstream, you have to make
use of the class
CharacterOutputStream.
D: To write an object to a file, you
use the class ObjectFileWriter.
Q.No.94 import java.awt.*; A: compile error C
public class Test extends Frame { B: three components will appear,
public static void main(String [] args) { Label at North, TextField at South
and Button at Center.
new Test();
C: only one Button at the Center
} D: Frame will appear, but nothing
Test () { there
add( new Label(“Hello”) );
add( new TextField(“World”) );
add( new Button(“Ok”) );
pack();
show();
}
}
what is the result?
Q.No.95 Which of the following statements A: Swing exists since version 1.2 D
about GUI components is wrong? of the jdk.
B: AWT stands for Abstract
Q. No. 131
Question:
Which of the following statements about the Java language is true?
Answer Choices
A: Java supports only Procedural approach towards programming
B: Both Procedural and Object Oriented Programming are supported in Java
C: Java supports only Object Oriented Programming approach
D: None of the these.
Q.No 132.
Question:
What is garbage collection in context of Java?
Infoway Technologies Pvt. Ltd., Pune Page 46 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Answer Choices
A: The operating system periodically deletes all of the java files available on the system.
B: Any package imported in a program and not used is automatically deleted.
C: When all references to an object are gone, the memory used by the object is
automatically reclaimed.
D: The JVM checks the output of any Java program and deletes anything that
doesn't make sense.
Q.No 133.
Question:
A constructor
Answer Choices
A: must have the same name as the class it is declared within.
B: is used to create objects.
C: may be declared private
D: All of the above
Q.No 134.
Question:
Which of the following is TRUE?
Answer Choices
A: In java, an instance field declared public generates a compilation error.
B: int is the name of a class available in the package java.lang
C: Instance variable names may only contain letters and digits.
D: A class has always a constructor (possibly automatically supplied by the java
compiler).
Q.No 135.
Question:
What is different between a Java applet and a Java application?
Q.No 136.
Question:
Why we use array as a parameter in Java methods
Answer Choices
A: It is syntax B: Can store multiple values as arguments
C: Both of above. D: None of above
Q.No 137.
Question:
In java, gc() method is available in which package
Answer Choices
A: java.lang package B: java.util package
C: java.awt package D: java.io package
Q.No 138.
Question:
Which command is used for interpretation of java program
Answer Choices
A: java B: javac
C: javap D: none of above
Q.No 139.
Question:
The inner class can access private members of the outer class
Q.No 140.
Question:
Answer Choices
A: MyOuter.MyInner m = new MyOuter.MyInner();
B: MyOuter.MyInner mi = new MyInner();
C: MyOuter m = new MyOuter();
MyOuter.MyInner mi = m.new MyOuter.MyInner();
D: MyInner mi = new MyOuter.MyInner();
Q.No 141.
Question:
A package is a collection of
Answer Choices
A: classes and interfaces B: classes
C: interfaces D: editing tools
Q.No 142.
Question:
Answer Choices
A: x = 0 B: x = 1
C: Compilation fails. D: An exception is thrown at runtime.
Q.No 143.
Question:
What will be the output of the program?
public class RTExcept
{
public static void throwit ()
{
System.out.print("throwit ");
throw new RuntimeException();
}
public static void main(String [] args)
{
Answer Choices
A: hello throwit caught
B: Compilation fails
C: hello throwit RuntimeException caught after
D: hello throwit caught finally after
Q.No 144.
Question:
Which statement is true?
Answer Choices
A: catch(X x) can catch subclasses of X where X is a subclass of Exception.
B: The Error class is a RuntimeException.
C: Any statement that can throw an Error must be enclosed in a try block.
D: Any statement that can throw an Exception must be enclosed in a try block.
Q.No 145.
Answer Choices
A: 2 B: 3 C: 4 D: 2,5
Q.No 146.
Question:
public class Myfile
{
public static void main (String[] args)
{
String biz = args[1];
String baz = args[2];
String rip = args[3];
System.out.println("Arg is " + rip);
}
}
Select how you would start the program to cause it to print: Arg is 2
Answer Choices
A: java Myfile 222 B: java Myfile 1 2 2 3 4
C: java Myfile 1 3 2 2 D: java Myfile 0 1 2 3
Q.No 147.
Question:
Which of these interface handle sequences?
Answer Choices
A: Set B: List C: Comparator D: Collection
Q.No 148
Answer Choices
A: Native methods are usually used to interface with system calls or libraries written
in other programming languages.
B: Native methods are as same like as abstract method.
C: Both of these.
D: None of these.
Q.No 149.
Question:
Which class does not override the equals() and hashCode() methods, inheriting them directly
from class Object?
Answer Choices
A: java.lang.String B: java.lang.Double
C: java.lang.StringBuffer D: java.lang.Character
Q.No 150.
Question:
Which interface does java.util.Hashtable implement?
Answer Choices
A: Java.util.Map B: Java.util.List
C: Java.util.HashTable D: Java.util.Collection
Q.No 151.
Question:
Which collection class allows you to associate its elements with key values, and allows you
to retrieve objects in FIFO (first-in, first-out) sequence?
Answer Choices
A: java.util.ArrayList B: java.util.LinkedHashMap
Q.No 152.
Question:
Suppose that you would like to create an instance of a new Map that has an iteration order
that is the same as the iteration order of an existing instance of a Map. Which concrete
implementation of the Map interface should be used for the new instance?
Answer Choices
A: TreeMap
B: HashMap
C: LinkedHashMap
D: The answer depends on the implementation of the existing instance.
Q.No 153.
Question:
What will be the output of the program?
package foo;
import java.util.Vector; /* Line 2 */
private class MyVector extends Vector
{
int i = 1; /* Line 5 */
public MyVector()
{
i = 2;
}
}
public class MyNewVector extends MyVector
{
public MyNewVector ()
{
i = 4; /* Line 15 */
}
public static void main (String args [])
Answer Choices
A: Compilation will succeed. B: Compilation will fail at line 3.
C: Compilation will fail at line 5. D: Compilation will fail at line 15.
Q.No 154.
Question:
Thread priority in Java is?
Answer Choices
A: Integer B: Float C: double D: long
Q.No 155.
Question:
What is the output of this program?
1. class multithreaded_programing {
2. public static void main(String args[]) {
3. Thread t = Thread.currentThread();
4. System.out.println(t);
5. }
6. }
Answer Choices
A: Thread[5,main] B: Thread[main,5]
C: Thread[main,0] D: Thread[main,5,main]
Q.No 156.
Question:
Which of these method is used to explicitly set the priority of a thread?
Q.No 157.
Question:
What is the output of this program?
1. class newthread extends Thread {
2. Thread t;
3. newthread() {
4. t1 = new Thread(this,"Thread_1");
5. t2 = new Thread(this,"Thread_2");
6. t1.start();
7. t2.start();
8. }
9. public void run() {
10. t2.setPriority(Thread.MAX_PRIORITY);
11. System.out.print(t1.equals(t2));
12. }
13. }
14. class multithreaded_programing {
15. public static void main(String args[]) {
16. new newthread();
17. }
18. }
Answer Choices
A: true B: false C: truetrue D: falsefalse
Q.No 158.
Question:
Which of these is a process of writing the state of an object to a byte stream?
Answer Choices
A: Serialization B: Externalization
Q.No 159.
Question:
What is the output of this program?
1. import java.io.*;
2. class serialization {
3. public static void main(String[] args) {
4. try {
5. Myclass object1 = new Myclass("Hello", -7, 2.1e10);
6. FileOutputStream fos = new FileOutputStream("serial");
7. ObjectOutputStream oos = new ObjectOutputStream(fos);
8. oos.writeObject(object1);
9. oos.flush();
10. oos.close();
11. }
12. catch(Exception e) {
13. System.out.println("Serialization" + e);
14. System.exit(0);
15. }
16. try {
17. Myclass object2;
18. FileInputStream fis = new FileInputStream("serial");
19. ObjectInputStream ois = new ObjectInputStream(fis);
20. object2 = (Myclass)ois.readObject();
21. ois.close();
22. System.out.println(object2);
23. }
24. catch (Exception e) {
25. System.out.print("deserialization" + e);
26. System.exit(0);
27. }
28. }
29. }
Answer Choices
A: s=Hello; i=-7; d=2.1E10
B: Hello; -7; 2.1E10
C: s; i; 2.1E10
D: Serialization
Q.No 160.
Question:
Which of these process occur automatically by java run time system?
Answer Choices
A: Serialization B: Garbage collection
C: File Filtering D: All of the mentioned
Q.No 161.
Question:
Which of these class is used to read characters in a file?
Answer Choices
A: FileReader B: FileWriter
C:FileInputStream D: InputStreamReader
Q.No 162.
Answer Choices
A: start() method B: init() method
C: stop() method D: destroy() method
Q.No 163.
Question:
Package of drawstring() method is
Answer Choices
A: java.applet B: java.io
C: javax.swing D: java.awt
Q.No 164.
Question:
Clicking a mouse button will always generate which event?
Answer Choices
A: MouseButtonEvent B: ActionEvent
C: MouseClickEvent D: MouseEvent
Q.No 165.
Question:
When we invoke repaint() for a java.awt.Component object, the AWT invokes the method:
Answer Choices
A: draw() B: show()
C: paint() D: update()
Q.No 166.
Question:
Program which executes applet is known as
Answer Choices
A: applet engine B: virtual machine
C: JVM D: None of above
Q.No 167
Question:
Which method of the Applet class displays the result of applet code on screen
Answer Choices
A: run() method B: paint() method
C: drawString() method D: main() method
Q.No 168.
Question:
Executable applet is
Answer Choices
A:.applet file B:.java html
C:.java file D:class file
Q.No 169.
Question:
Which of the following below are abilities of Reflection API in Java?
Answer Choices
A: Determining state of an object
B: Both B and C
C: Determining duplicate classes
D: Determination of the class of an object
Q.No 170.
Question:
RMI stands for
Answer Choices
A: Remote Method Invocation B: Remote method invention
C: Remote Memory Interface D: Reduced Method Instruction
Q.No 171.
Question:
Which of these is a protocol for breaking and sending packets to an address across a
network?
Answer Choices
A: TCIP/IP B: DNS C: Socket D: Proxy Server
Q.No 172.
Question:
Which of these class is used to encapsulate IP address and DNS?
Answer Choices
A: DatagramPacket B:URL
C: InetAddress D: ContentHandler
Q.No 173.
Question:
What is the output of this program?
1. import java.net.*;
2. class networking {
3. public static void main(String[] args) throws UnknownHostException {
4. InetAddress obj1 = InetAddress.getByName("sanfoundary.com");
5. InetAddress obj2 = InetAddress.getByName("sanfoundary.com");
6. boolean x = obj1.equals(obj2);
7. System.out.print(x);
8. }
9. }
Q. No. 174
Question:
Which of the following java component is platform independent?
Answer Choices
A: Java source code B: JVM
C: Java (.class ) file D: Both a and c
Q. No. 175
Question:
Which of the following is true for JVM?
Answer Choices
A: it is a compiler
B: it is an interpreter with JIT compiler
C: it is a microprocessor
D: it is platform independent
Q. No. 176
Question:
If one java source file contains 5 classes how many .class files will be generated on
compilation?
Answer Choices
A: one B: five C: cannot say D: two
Difficulty Level: Easy
Q. No. 177
Question:
Q. No. 178
Question:
Which of the following is the prototype of entry point main method?
Answer Choices
A: public static void main(String args)
B: public void main(String[] args)
C: public static int main(String[] args)
D: public static void main(String[] args)
Difficulty Level: Easy
Q. No. 179
Question:
Which of the following commands should be used to compile a packaged class and create
the package in the current directory?
Answer Choices
A: javac B: javac -d .
C: javac -create D: none of the above
Q. No. 180
Question:
Which of the following can be written outside a class in java?
Answer Choices
A: Method B: Field declaration
C: import statement D: Static fields
Q. No. 181
Question:
What is the correct order of scope specifiers in java from narrowest to broadest?
Answer Choices
A: private protected default public
B: private default protected public
C: default private protected public
D: private protected default public
Difficulty Level: Intermediate
Q. No. 182
Question:
Which of the following is true about constructors in java?
Answer Choices
A: If no constructor is written class cannot compile
B: If no constructor is written class gets a default no argument constructor
automatically
C: If only one parameterized constructor is written in the class then the class also gets one
default no argument constructor
D: All the above
Difficulty Level: Intermediate
Q. No. 183
Question:
Which scope specifier can be used for outer class of java?
Answer Choices
A: public B: private
C: Both A and B D: protected
Difficulty Level: Easy
Q. No. 184
Q. No. 185
Question:
Which of the following are true for arrays in java?
Answer Choices
A: arrays are always objects
B: arrays are created using new
C: we can have object arrays and primitive arrays
D: all the above
Q. No. 186
Question:
What is process of defining two or more methods within same class that have same name
but different parameters declaration?
Answer Choices
A: Method overloading B: Method overriding
C: Method hiding D: None of the above
Q. No. 187
Question:
Which of the following methods can be overridden?
Answer Choices
A: static methods B: non-static methods
C: constructors D: all the above
Difficulty Level: Intermediate
Q. No. 188
Question:
Which of these packages contain all the collection classes?
Answer Choices
A: java.lang B: java.util
C: java.io D: None of the above
Q. No. 189
Question:
The socket in java socket programming represents which of the following-
Answer Choices
A: IP address of the machine
B: IP and port number of the process
C: Port number of the process
D: Physical socket for inserting network cable
Difficulty Level: Intermediate
Q. No. 190
Question:
The socket connection established using the DatagramSocket and DatagramPacket classes
is of which of the following types?
Answer Choices
A: TCP socket
B: UDP socket
C: Physical socket for inserting network cable
D: None of the above
Q. No. 191
Question:
For socket programming we require_____________.
Answer Choices
A: only one JVM B: at least 2 JVMs running
C: A and B D: none
Q. No. 192
Question:
The InetAdress class represents which of the following?
Answer Choices
A: IP address B: Host name
C: Both A and B D: None of the above
Q. No. 193
Question:
The ServerSocket class represents which of the following?
Answer Choices
A: Socket of the server process B: Socket of the client process
C: Both and b D: None of the above
Q. No. 194
Question:
Which is true for DatagramSocket connection?
Answer Choices
A: A stream is created between client and server
B: No sequence of datagram packets is maintained
C: It is a reliable connection
D: It is not useful for video data transfer
Q. No. 195
Question:
Which of the following can be used to run an applet?
Answer Choices
A: Appletviewer B: Browser
Q. No. 196
Question:
Which of the following method is called when an applet window is minimized?
Answer Choices
A: init B: start
C: stop D: destroy
Q. No. 197
Question:
Which class represents the document containing the applet ?
Answer Choices
A: AppletContext B: Document
C: Container D: None of the above
Q. No. 198
Question:
What is the Listener for Button Click in Swing?
Answer Choices
A: ButtonListener B: ActionListener
C: WindowListener D: MouseListener
Q. No. 199
Question:
What is the Listener for Mouse Click in Swing?
Answer Choices
A: ButtonListener B: ActionListener
C: WindowListener D: MouseListener
Q. No. 200
Question:
Which of the following packages contain all event handling packages in java GUI?
Answer Choices
A: java.applet B: java.awt.event
C: javax.event D: All the above
Q. No. 201
Question:
All java classes are derived from ________.
Answer Choices
A: java.lang.Class B: java.lang.Object
C: java.awt.Window D: None the above
Q. No. 202
Question:
What would happen if "String[]args" is not included as argument in the main method.
Answer Choices
A: Compilation error B: Program will not exit
C: Program will not run D: None the above
Q. No. 203
Question:
Which method will a web browser call on a new applet?
Answer Choices
A: main method B: init method
C: execute method D: run method
Q. No. 204
Question:
Which method will be called when threads are created and they start execution in java?
Answer Choices
A: main method B: init method
C: execute method D: run method
Q. No. 205
Question:
State true of false.
i) AWT is an extended version of swing
ii) Paint( ) of Applet class cannot be overridden
Answer Choices
A: i-false, ii-false B: i-false, ii-true
C: i-true, ii-false D: i-true, ii-true
Q. No. 207
Question:
1. class X {
2. int a;
3. double b;
4. }
5. class Y extends X {
6. int c;
7. }
8. class Output {
9. public static void main(String args[]) {
Infoway Technologies Pvt. Ltd., Pune Page 70 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
X a = new X();
Y b = new Y();
Class obj;
obj = a.getClass();
System.out.print(obj.getName());
}
}
Answer Choices
A: X B: Y C: A D: B
Q. No. 208
Question:
1. class X {
2. int a;
3. double b;
4. }
5. class Y extends X {
6. int c;
7. }
8. class Output {
9. public static void main(String args[]) {
X a = new X();
Y b = new Y();
Class obj;
obj = b.getClass();
System.out.print(obj.getSuperclass());
}
}
Answer Choices
A: X B: Y C: Object D: Class
Q. No. 209
Question:
1. class X {
2. int a;
3. double b;
4. }
Infoway Technologies Pvt. Ltd., Pune Page 71 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
5. class Y extends X {
6. int c;
7. }
8. class Output {
9. public static void main(String args[]) {
X a = new X();
Y b = new Y();
Class obj;
obj = b.getClass();
System.out.print(b.equals(a));
}
}
Answer Choices
A: 0 B: 1
C: True D: false
Q. No. 210
Question:
Which of the following can be achieved through reflection?
Answer Choices
A: finding the method signatures of the class
B: creating objects dynamically
C: invoking methods dynamically
D: all the above
Q. No. 211
Question:
Which of the following is true for simple inner classes in java?
Answer Choices
A: inner classes can access the private members of outer class
B: outer class can access the private members of inner class
C: inner class has an independent entity without outer class
D: all the above
Q. No. 212
Question:
Which of the following is true?
Answer Choices
A: A class can extend more than one class
B: A class MUST implement only one interface
C: A class can extend only one class and can implement more than one interface
D: A class MUST extend only one class and MUST implements only one interface
Q. No. 213
Question:
An interface contains which of the following?
Answer Choices
A: Method declaration
B: Method definition
C: Method declaration and definition
D: None of these
Difficulty Level: Easy
Q. No. 214
Question:
Which of the following is true if the class implements an interface but does not override all its
methods?
Answer Choices
A: Class MUST declare all the methods
B: Class can be declared as abstract to compile
C: Class can be declared as final to compile
D: None of these
Difficulty Level: Easy
Q. No. 215
Question:
The variables of an interface by default have which of the following modifiers?
Answer Choices
Q. No. 216
Question:
The methods of an interface by default get which of the following modifiers?
Answer Choices
A: static B: final
C: static and final D: abstract
Q. No. 217
Question:
Which of these keywords can be used to prevent inheritance of a class?
Answer Choices
A: static B: Final
C: static and final D: Abstract
Q. No. 219
Question:
1. class A {
2. int i;
3. int j;
4. A() {
5. i = 1;
6. j = 2;
7. }
Infoway Technologies Pvt. Ltd., Pune Page 74 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
8. }
9. class Output {
public static void main(String args[])
{
A obj1 = new A();
A obj2 = new A();
System.out.print(obj1.equals(obj2));
} }
Answer Choices
A: true B: false
C: Compiler error D: Runtime error
Q. No. 220
Question:
1. class Output {
2. public static void main(String args[])
3. {
4. Object obj = new Object();
5. System.out.print(obj.getclass());
6. }
7. }
Answer Choices
A: Object B: Class
C: Compiler error D: Runtime error
Q. No. 221
Question:
Which of the following interface MUST be used to serialize an object over a socket?
Answer Choices
A: Serializable B: Cloneable
C: DataOutput D: DataInput
Q. No. 222
Q. No. 223
Question:
1. import java.io.*;
2. class files {
3. public static void main(String args[]) {
4. File obj = new File("/java/system");
5. System.out.print(obj.getName());
6. }
7. }
Answer Choices
A: Java B: System
C: java/system D: /java/system
Difficulty Level: Difficult
Q. No. 224
Question:
class A{
public static void main(String[] args){
System.out.println(“Hello World..!”);
int i=0;
if(i=0){
System.out.println(“I : ” + i);
}
}
}
Answer Choices:
A. Hello World..!
I: 0
B. Hello World..!
C. Compilation Error
D. None of the above
Difficulty Level: Easy
Infoway Technologies Pvt. Ltd., Pune Page 76 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Correct Answer: C
Q. No. 225
Question:
How can we create an unsigned int variable in Java?
Answer Choices
A. Cannot be created
B. unsigned int I;
C. int i=(unsigned int)10;
D. int unsigned I;
Difficulty Level: Easy
Correct Answer: A
Q. No. 226
Question:
What is not a true java statement?
Answer Choices:
A. Java de-allocates memory automatically.
B. Finalize method is just called before garbage collection.
C. Garbage collection runs when there is reference with the objects and runs periodically.
D. Inside finalize method we keep those code which must be executed before the object
is destroyed by garbage collection.
Difficulty Level: Easy
Correct Answer: D
Q. No. 227
Question:
Why we use array as a parameter of main method
Answer Choices
A. It is syntax
B. Can store multiple values
C. Both of above
D. None of the above
Difficulty Level: Intermediate
Q. No. 228
Question:
Arrange the following statements in correct order.
Statement 1: Running the Java command
Statement 2: Main method of that class is executed.
Statement 3: JRE is loaded along with the class you specify.
Answer Choices:
A. Statement: 3 2 1
B. Statement: 1 3 2
C. Statement: 1 2 3
D. Statement: 2 1 3
Difficulty Level: Easy
Correct Answer: B
Q. No. 229
Question:
What will be the output?
class A{
static void method(){
System.out.println(“Class A method”);
}
}
class B extends A{
static void method(){
System.out.println(“Class B method”);
}
}
public class Test{
public static void main(String args[]){
A a=new B();
a.method();
}
}
Answer Choices
A. Class A method
B. Class B method
C. Compilation error
D. Runtime Error
Q. No. 230
Question:
Can an interface have an inner class?
Answer Choices:
A. Yes
B. No
C. Syntax Error
D. Checked exception
Difficulty Level: Intermediate
Correct Answer: A
Q. No. 231
Question:
Which of the following are correct? Select the one correct answer.
Answer Choices
A. An import statement, if defined, must always be the first non-commented statement of
the file.
B. Private members are accessible to all classes in the same package in which the class
is defined.
C. An abstract class can be declared as final.
D. Local variables cannot be declared as static.
Difficulty Level: Easy
Correct Answer: D
Q. No. 232
Question:
Which of the following is true?
Answer Choices:
A. A class can extend more than one class.
B. A class can extend only one class but many interface.
C. An interface can implement many interfaces.
Q. No. 233
Question:
interface A { }
class C { }
class D extends C { }
class B extends D implements A { }
public class Test extends Thread{
public static void main(String[] args){
B b = new B();
if (b instanceof A)
System.out.println("b is an instance of A");
if (b instanceof C)
System.out.println("b is an instance of C");
}
}
Answer Choices
A. Nothing.
B. B is an instance of A.
C. B is an instance of C.
D. B is an instance of A followed by b is an instance of C.
Difficulty Level: Easy
Correct Answer: D
Q. No. 235
Question:
Which of the below statements is/are true about Error?
Answer Choices:
A. An error is a subclass of NullPointerException.
B. An error is a subclass of Exception
C. An error is a subclass of IOException
D. Error indicates serious problems that a reasonable application should not try to catch.
Difficulty Level: Easy
Correct Answer: D
Q. No. 237
Question:
String objects are stored in special memory area known as?
Q. No. 238
Question:
int Integer = 34 ;
char String = 'S' ;
System.out.print( Integer ) ;
System.out.print( String ) ;
Answer Choices
A. Does not compile as Integer and String are API class names.
B. Throws exception
C. 34 S
D. Prints nothing
Difficulty Level: Easy
Correct Answer: C
Q. No. 239
Question:
When you try to compile MyClass, the java compiler gives an error message
MyClass is not abstract and does not override abstract method in java.util.Comparator
Which of the following is in the error message?
Answer Choices:
A. Equals(myClass)
B. compareTo(myClass)
C. compare(java.lang.Object, java.lang.Object)
D. compare(myClass,myClass)
Difficulty Level: Easy
Correct Answer: C
Q. No. 240
Q. No. 241
Question:
In which an EJB container must provide an implementation of Java Naming and Directory
Interface (JNDI) API to provide naming services for EJB clients and components?
Answer Choices:
A. Transaction Support
B. Persistence Support
C. Naming Support
D. All the mentioned above
Difficulty Level: Easy
Correct Answer: C
Q. No. 242
Question:
Why we need JNDI if communication to systems via LDAP is possible?
Answer Choices
A. JNDI is used to lookup resources like a database or a message queue. With JNDI you
get a uniform way to access directory services.
B. Using JNDI multiple dbms can be reduced by centralizing the information.
C. JNDI is naming service its maps object with names.
D. JNDI is directory service where the user and resource information and machine
addresses are summarized by directory service
Q. No. 243
Question:
Which of the following in JavaFX is used to connect to the native Operating System?
Answer Choices:
A. Glass Windowing Toolkit
B. Prism
C. Media Engine
D. Web Engine
Difficulty Level: Easy
Correct Answer: A
Q. No. 244
Question:
What is the main entry point of the JavaFX application?
Answer Choices
A. main()
B. start()
C. initUI()
D. launch()
Difficulty Level: Easy
Correct Answer: B
Q. No. 245
Question:
public class Test implements Runnable{
public static void main(String[] args){
Test t = new Test();
t.start();
}
public void run() { }
}
Answer Choices:
A. The program does not compile because the start() method is not defined in the Test
class.
B. The program compiles, but it does not run because the start() method is not defined.
C. The program compiles, but it does not run because the run() is not implemented.
Infoway Technologies Pvt. Ltd., Pune Page 84 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
D. The program compiles and runs fine.
Difficulty Level: Easy
Correct Answer: A
Q. No. 246
Question:
class A implements Runnable{
public void run(){
try{
for(int i=0;i<4;i++){
Thread.sleep(100);
System.out.println(Thread.currentThread().getName());
}
}catch(InterruptedException e){
}
}
}
Q. No. 247
Question:
What does notifyAll() method do?
Answer Choices:
A. Wakes up all threads that are waiting on this object’s monitor
Q. No. 248
Question:
Which keyword when applied on a method indicates that only one thread should execute the
method at a time.
Answer Choices
A. volatile
B. synchronized
C. final , static
D. native
Difficulty Level: Easy
Correct Answer: B
Q. No. 249
Question:
Which of these classes defined in java.io and used for file-handling are abstract?
A. InputStream
B. PrintStream
C. Reader
D. FileInputStream
E. FileWriter
Answer Choices:
A. only A
B. B and D
C. A and C
D. A, B and E
Difficulty Level: Easy
Correct Answer: C
Q. No. 251
Question:
Which is the container that contains the title bar and can have menu bar? It can have other
components like TextFields, Buttons etc?
Answer Choices:
A. Window
B. Frame
C. Panel
D. Container
Difficulty Level: Easy
Correct Answer: B
Q. No. 252
Question:
In which place can we put event handling code?
Answer Choices
A. Same class
B. Other class
C. Anonymous class
D. All the above
Difficulty Level: Easy
Correct Answer: D
Answer Choice:
A. Window
B. Panel
C. Frame
D. Container
Q. No. 254
Question
Q. No. 256
Question:
The Swing Component classes that are used in Encapsulates a mutually exclusive set of
buttons?
Answer Choices
A. AbstractButton
B. ButtonGroup
C. JButton
D. ImageIcon
Difficulty Level: Easy
Correct Answer: B
Q. No. 257
Question:
What is the output of the following applet code?
import java.awt.*;
import java.applet.*;
public class myapplet extends Applet {
public void paint(Graphics g) {
g.drawString("A Simple Applet", 20, 20);
}
}
Answer Choices:
A. A Simple Applet
B. A Simple Applet 20 20
C. Compilation Error
D. Runtime Error
Difficulty Level: Easy
Correct Answer: A
Q. No. 258
Question:
What is the first method called by an applet?
Answer Choices
A. start()
Q. No.259
Question:
Which class provides the facility of Inter applet communication?
Answer Choice:
A. Applet
B. AppletContext
C. Class
D. Graphics
Difficulty Level: Easy
Correct Answer: B
Q. No. 260
Question:
What is immediate superclass of Applet class?
Answer Choices
A. Panel
B. Frame
C. Component
D. Container
Difficulty Level: Intermediate
Correct Answer: A
Q. No. 261
Question:
Which class is the entry point for reflection?
Answer Choices:
A. Java.lang.Object
B. Java.lang.Class
Q. No. 262
Question:
import java.lang.reflect.Method;
class Demo{
private int x;
private int y;
}
Answer Choices
A. Something’s going wrong…………..
B. Demo [x=10 y=10 ]
C. Compilation Error
D. None of the above.
Difficulty Level: Easy
Correct Answer: A
Q. No. 263
Question:
Which of these class is used to create servers that listen for either local or remote client
programs?
Answer Choices:
A. httpServer
B. ServerSocket
C. MIMEHeader
D. HttpResponse
Difficulty Level: Easy
Correct Answer: B
Q. No. 264
Question:
Which of these class is used to encapsulate IP Address and DNS?
Answer Choices
A. URL
B. DatagramPacket
C. InetAddress
D. ContentHandler
Difficulty Level: Easy
Correct Answer: C
Q. No. 265
Question:
Which constructor of DatagramSocket class is used that it creates a datagram socket and
binds it with the given Port Number?
Answer Choices:
A. DatagramSocket(int port)
B. DatagramSocket(int port, InetAddress address)
C. DatagramSocket()
D. None of the above
Difficulty Level: Easy
Correct Answer: B
Q. No. 266
Question:
Which combination of family and type of socket is used to create a datagram
socket
Answer Choice
A. AF_ROUTE, SOCK_DGRAM
B. AF_INET, SOCK_DGRAM
C. AF_KEY, SOCK_DGRAM
D. AF_INET, SOCK_STREAM
Difficulty Level: Intermediate
Correct Answer: B
Q. No. 267
Question:
If you are writing a server program which will be run on a multi-homed machine then
to which IP address and Port number do you prefer to bind your server.
Answer Choices
A. well-known IP address and ephemeral Port number
B. Wildcard IP address and ephemeral Port number
C. Wildcard IP address and well-known Port number
D. well-known IP address and Port number
Difficulty Level: Easy
Correct Answer: D