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

Java Technologies I

All java technologies

Uploaded by

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

Java Technologies I

All java technologies

Uploaded by

Sudhir Kindarley
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 93

Java Technologies I

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 1
Question: Which declaration of the main method below would allow a class to be
started as a standalone program.

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 2
Question: What gets printed when the following code is compiled and run with the
following command -
java test 2
public class test {
public static void main(String args[]) {
Integer intObj=Integer.valueOf(args[args.length-1]);
int i = intObj.intValue();

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/

Infoway Technologies Pvt. Ltd., Pune Page 1 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 3
Question: The constructor of a class must not have a return type.

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 4
Question: What all gets printed when the following program is compiled
and run.

public class test {


public static void main(String args[]) {
int i=0, j=2;
do {
i=++i;
j--;
} while(j>0);
System.out.println(i);

}
}

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 5
Question: How can you ensure that the memory allocated by an object is freed?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 6
Question: What gets printed when the following code is compiled and run.

public class test {


public static void main(String args[]) {
int i = 1;
do {
i--;
} while (i > 2);
System.out.println(i);
}
}

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 7
Question: Which of these is a legal definition of a method named m assuming it
throws IOException, and returns void. Also assume that the method
does not take any arguments.
Answer Choices
Choice 1: void m() throws IOException{}
Choice 2: void m() throw IOException{}
Choice 3: void m(void) throws IOException{}
Choice 4: m() throws IOException{}
Correct Answer: Choice 1
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 8
Question: String s = new String("xyz");
Assuming the above declaration, which of the following
statements would compile.
Answer Choices
Choice 1: s = 2 * s;
Choice 2: int i = s[0];
Choice 3: s = s + s;
Choice 4: s = s >> 2;
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 9

Infoway Technologies Pvt. Ltd., Pune Page 4 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Question: Which keyword when applied on a method indicates that only one
thread should execute the method at a time.

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 10
Question: What is the name of the Collection interface used to represent elements
in a sequence (in a particular order).

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 11
Question: What gets written on the screen when the following program is compiled
and run. Select the one right answer.

public class test {


public static void main(String args[]) {
int i;
float f = 2.3f;
double d = 2.7;
i = ((int)Math.ceil(f)) * ((int)Math.round(d));

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 12
Question: Which method defined in Integer class can be used to convert an Integer
object to primitive int type.

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 13
Question: Which of the following are correct.

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.)

Infoway Technologies Pvt. Ltd., Pune Page 6 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 14
Question: The default layout manager for a Frame is ...

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 15
Question: Which is the only layout manager that always honors the size of a
component.

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 16
Question: What will happen when you attempt to compile and run the following code

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();
}

abstract void hallow(){


System.out.println("Claines "+i);
}

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

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 17
Question: import java.awt.*;

public class Test extends Frame {


public static void main(String [] args) {
new Test();
}
Test () {
add( new Label(“Hello”) );
add( new TextField(“World”) );
add( new Button(“Ok”) );
pack();
show();
}
}

what is the result?

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

Infoway Technologies Pvt. Ltd., Pune Page 8 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Choice 4: Frame will appear, but nothing there
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 18
Question: Which of the following statements are true?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 19
Question: int i=1; int j=10;

do{
if(i>j) continue;
j--;
}while(++i<6);

After execution, what are the value for i and j?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 20
Question: Which of the following are methods of the Runnable interface

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 21
Question: In the following pieces of code, A and D will compile without any error.
True/False?
A: StringBuffer sb1 = "abcd";
B: Boolean b = new Boolean("abcd");
C: byte b = 255;
D: int x = 0x1234;
E: float fl = 1.2;
Answer Choices
Choice 1: True
Choice 2: False
Choice 3:
Choice 4:
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
Infoway Technologies Pvt. Ltd., Pune Page 10 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
taken from book/
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 22
Question: What results from attempting to compile and run the following code?
public class Ternary
{
public static void main(String args[])
{
int a = 5;
System.out.println("Value is - " + ((a < 5) ? 9.9 : 9));
}
}

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 23
Question: Given the code below, and making no other changes, which access
modifiers (public, protected or private) can legally be placed before
myMethod() on line 3? If line 3 is left as it is, which keywords can legally
be placed before myMethod on line 8?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 24
Question: What results from the following code?

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

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 25
Question: What will be printed when you execute the following code?

class X
{
Y b = new Y();
X()
{
System.out.print("X");
}
}

class Y
{
Y()
{
System.out.print("Y");
}
}

public class Z extends X


{
Y y = new Y();

Z()
{
System.out.print("Z");
}

public static void main(String[] args)


{
new 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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 26
Question: What will happen when you attempt to compile and run the following
code?

class Base
{
int i = 99;

public void amethod()


{
System.out.println("Base.amethod()");
}
Base()
{
amethod();
}
}

public class Derived extends Base


{
int i = -1;

public static void main(String argv[])


{
Base b = new Derived();
System.out.println(b.i);
b.amethod();
}

public void amethod()


{
System.out.println("Derived.amethod()");
}

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

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 27
Question: What will be the output on compiling/running the following code?

public class MyThread implements Runnable


{
String myString = "Yes ";

public void run()


{
this.myString = "No ";
}

public static void main(String[] args)


{
MyThread t = new MyThread();
new Thread(t).start();

for (int i=0; i < 10; i++)


System.out.print(t.myString);
}
}
Answer Choices
Choice 1: Compilation Error
Choice 2: Prints : Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes and so on.
Choice 3: Prints : Yes No Yes No Yes No Yes No Yes No and so on.
Choice 4: The output cannot be determined.
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 15 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Topic / Module: Java Technology J2SE- Core Java
Q. No.: 28
Question: Which of the following statements are true.

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 29
Question: What code placed after the comment // Start For loop would result in the
population of every element of the array ia[] with a value from variable i.?
public class Lin{
public static void main(String argv[]){
Lin l = new Lin();
l.amethod();
}
public void amethod(){
int ia[] = new int[4];
//Start For loop
{
ia[i]=i;
System.out.println(ia[i]);
}
}
}
Answer Choices
Choice 1: for(int i=0; i < ia.length() -1; i++)
Choice 2: for (int i=0; i< ia.length(); i++)
Choice 3: for(int i=1; i < 4; i++)
Choice 4: for(int i=0; i< ia.length;i++)
Infoway Technologies Pvt. Ltd., Pune Page 16 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Correct Answer: Choice 4
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 30
Question: Given the following code what will be output?
public class Pass{
static int j=20;
public static void main(String argv[]){
int i=10;
Pass p = new Pass();
p.amethod(i);
System.out.println(i);
System.out.println(j);
}

public void amethod(int x){


x=x*2;
j=j*2;
}
}

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 31
Question: How can you change the current working directory using an instance of
the File class called FileName?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 32
Question: Given the following code, what test would you need to put in place of the
comment line?
//place test here
to result in an output of the string
Equal
public class EqTest{
public static void main(String argv[]){
EqTest e=new EqTest();
}

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.)

Infoway Technologies Pvt. Ltd., Pune Page 18 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Topic / Module: Java Technology J2SE- Core Java
Q. No.: 33
Question: Which of the following statements about this code are true?
public class Moreclass{
public static void main(String argv[]){
Moreclass m = new Moreclass();
m.go(new Turing(){});
}
public void go(Turing t){
t.start();
}

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

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 34
Question: An Applet has its Layout Manager set to the default of
FlowLayout. What code would be correct to change to another
Layout Manager.

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 35
Question: What will happen when you attempt to compile and run the
following code?
public class Holt extends Thread{
private String sThreadName;
public static void main(String argv[]){
Holt h = new Holt();
h.go();
}
Holt(){}

Holt(String s){
sThreadName = s;
}
public String getThreadName(){
return sThreadName;
}

public void go(){


Holt first = new Holt("first");
first.start();
Holt second = new Holt("second");
second.start();
}

public void start(){


for(int i = 0; i < 2; i ++){
System.out.println(getThreadName() +i);
try{
Thread.sleep(100);
} catch(InterruptedException
e){System.out.println(e.getMessage());}
}
}
}

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 36
Question: What is the result of the following operation?
System.out.println(4 | 3);

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 37
Question: Given the following declarations
String s1=new String("Hello")
String s2=new String("there");
String s3=new String();
Which of the following are legal operations?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 38
Question: If you wanted to find out where the position of the letter v (ie
return 2) in the string s containing "Java", which of the
following could you use?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 39
Question: If you run the code below, what gets printed out?
String s=new String("Bicycle");
int iBegin=1;
char iEnd=3;
System.out.println(s.substring(iBegin,iEnd));

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.)

Topic / Module: Java Technology J2SE- Core Java


Infoway Technologies Pvt. Ltd., Pune Page 22 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q. No.: 40
Question: What is the output of the following statement
System.out.println(Math.sqrt(-4));

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 41
Question: class Y is a subclass of class X. Will this compile?
Y myY = new X();

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 42
Question: Class Y is a subclass of class X. Will this compile?
X myX = new X();
Y myY = (Y)myX;

Answer Choices
Choice 1: Yes
Choice 2: No
Choice 3:
Choice 4:
Correct Answer: Choice 1

Infoway Technologies Pvt. Ltd., Pune Page 23 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 43
Question: Given these classes in different files:
package xcom;
public class Useful
{
int increment(int x) { return ++x; }
}
import xcom.*; // line 1
class Needy3
{
public static void main(String[] args)
{
xcom.Useful u = new xcom.Useful(); // line 2
System.out.println(u.increment(5));
}
}

Which statements are true?


Answer Choices
Choice 1: The output is 0.
Choice 2: The output is 5.
Choice 3: The output is 6.
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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 44
Question: Given:

import static java.lang.System.*;


class
{
static public void main(String... __A_V_)
Infoway Technologies Pvt. Ltd., Pune Page 24 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
{
String $ = "";
for(int x=0; ++x < __A_V_.length; )
$ += __A_V_[x];
out.println($);
}
}

And the command line:


java _ - A .

What is the result?


Answer Choices
Choice 1: -A
Choice 2: A
Choice 3: Compilation error
Choice 4: Error at runtime
Correct Answer: Choice 2
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 45
Question: Given two files:
a = b.java
c_d.class

Are in the current directory, which command-line invocation(s) could


complete without error?

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.)

Infoway Technologies Pvt. Ltd., Pune Page 25 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Topic / Module: Java Technology J2SE- Core Java
Q. No.: 46
Question: Given:
class TestProps
{
public static void main(String[] args)
{
String s = System.getProperty("aaa","bbb");
}
}

And the command-line invocation:


java -Daaa=ccc TestProps

What is always true?


Answer Choices
Choice 1: The value of property aaa is aaa.
Choice 2: The value of property aaa is bbb.
Choice 3: The value of property aaa is ccc.
Choice 4: The value of property bbb is aaa
Correct Answer: Choice 3
Difficulty Level: Easy / Intermediate / Difficult (To be marked by review team)
Reference:
(If question
taken from book/
website/etc.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 47
Question: finalize( ) is only called just prior to _________

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.)

Infoway Technologies Pvt. Ltd., Pune Page 26 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Topic / Module: Java Technology J2SE- Core Java
Q. No.: 48
Question: Given:
class Scoop {
static int thrower() throws Exception { return 42; }
public static void main(String [] args)
{
try {
int x = thrower();
} catch (Exception e) {
x++;
} finally {
System.out.println("x = " + ++x);
}
}
}

What is the result?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 49
Question: Given:
class Alien
{
String invade(short ships) { return "a few"; }
String invade(short... ships) { return "many"; }
}
class Defender
{
public static void main(String [] args)
{
System.out.println(new Alien().invade(7));
}
}
Infoway Technologies Pvt. Ltd., Pune Page 27 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
What is the result?

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.)

Topic / Module: Java Technology J2SE- Core Java


Q. No.: 50
Question: Given:
class Mixer
{
Mixer() { }
Mixer(Mixer m) { m1 = m; }
Mixer m1;
public static void main(String[] args)
{
Mixer m2 = new Mixer();
Mixer m3 = new Mixer(m2); m3.go();
Mixer m4 = m3.m1; m4.go();
Mixer m5 = m2.m1; m5.go();
}
void go() { System.out.print("hi "); }
}

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.)

Infoway Technologies Pvt. Ltd., Pune Page 28 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Questions Answer Option Correct
(Only 4 options to be given : A, B, Answer
C and D) (only one
option)
Q.No.51 Which assignments are illegal? A: long test = 012; C
B: float f = -412;
C: int other = (int)true;
D: double d = 0x12345678;
Q.No.52 What is the result of this program? A: This code compiles, runs and C
class Over displays over
{ followed by Under
public static void main(String[] args){ B: This code compiles, runs and
Under u = new Under(); displays Under
u.test(); followed by over
} C: This code does not compile
int test(){ D: Code will compile but gives
System.out.println("over"); runtime error
return 1;
}
}
class Under extends Over{
short test(){
super.test();
System.out.println("Under");
return 1;
}
}
Q.No.53: Which of the following represents A: 0x12 C
an octal number? B: 32O
C: 032
D: (octal)2

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?

Infoway Technologies Pvt. Ltd., Pune Page 29 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.55 Which statement about garbage A: You can directly free the A
collection is false? memory allocated by an object.
B: You can directly run the
garbage collector whenever you
want to.
C: The garbage collector informs
your object when it is about to be
garbage collected.
D: The garbage collector runs in
low-memory situations.
Q.No.56 What will be the result of A: It will print 'Equal' C
attempting to compile and run the following B: It will print 'Not Equal'
program? C: Compilation error as there is no
public class TestClass reverse ()
{ method in class String
public static void main(String args[ ] ){ D: Runtime error
String s = "hello";
StringBuffer sb = new StringBuffer("hello");
sb.reverse();
s.reverse();
if( s = = sb.toString() )
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}
Q.No.57 What will happen when you try to A: The code compiles and displays C
compile and run the following program? "mpg: 50" if the command-line
class Car argument is "Highway". If the
{ command-line argument is not
int milesPerGallon; "Highway", the code displays
int index; "mpg: 25".
Car(int mpg) { B: The code compiles and displays
milesPerGallon = mpg; "mpg: 50" if the command-line
index = 0; argument is "Highway". If the
} command-line argument is not
Car() "Highway", the code throws an
{ ArrayIndexOutOfBoundsException.
} C: The code does not compile
public static void main(String[] args) because the automatic variable
{ named index has not been
int index; initialized.
Car c = new Car(25); D: The code does not compile
if (args.length > 0) because milesPerGallon has not
if (args[index].equals("Highway")) been initialized.
milesPerGallon*= 2;
System.out.println("mpg: " +
milesPerGallon);
}
}
Infoway Technologies Pvt. Ltd., Pune Page 30 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.58 What will be the output of the A: Give compilation error A
following code? B: arithmetic exception
public class exception_demo C: arithmetic exception
{ D: None of the above
public static void main(String str[])
{
int i=1, j=1;
try
{
i++;
j--;
if(i/j > 1)
i++;
}
catch(Exception e)
{
System.out.println(“Exception”);
}
catch(ArithmeticException e)
{
System.out.println(“arithmetic exception”);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println(“Array index exception”);
}
finally
{
System.out.println(“finally”);
}
System.out.println(“after exceptions ”);
}
}
Q.No.59 Consider the code below: A: It will not compile because cube B
class Test is already defined in the
{ java.lang.Math class.
public static void main(String args[]) B: It will not compile because cube
{ is not static.
int a = 5; C: It will compile, but throw an
System.out.println( cube( a ) ); arithmetic exception.
} D: It will run perfectly and print
int cube( int theNum ) "125" to standard output.
{
return theNum * theNum * theNum;
}
}
What will happen when you attempt to
compile and run this code?

Infoway Technologies Pvt. Ltd., Pune Page 31 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.60 Suppose you create a class A: The program compiles fine, but B
Cylinder to be a you cannot create an instance of
subclass of Circle. Analyze the following Cylinder because the constructor
code: does not specify the length of the
cylinder.
class Cylinder extends Circle B: The program has a syntax error
{ because you attempted to invoke
double length; the Circle class's constructor
Cylinder(double radius) illegally.
{ C: The program compiles fine, but
Circle(radius); it has a runtime error because of
} invoking the Circle class’s
} constructor illegally.
D: None of the above
Q.No.61 will appear in the standard output A: "good-bye" followed by "hello" A
when you run the Tester class? B: "hello"
class Tester { C: 5
int var; D: "hello" followed by "good-bye"
Tester(double var) {
this.var = (int)var;
}
Tester(int var) {
this("hello");
}
Tester(String s) {
this();
System.out.println(s);
}
Tester() {
System.out.println("good-bye");
}
public static void main(String[] args) {
Tester t = new Tester(5);
}
}
Q.No.62 Analyze the following code: A: The program cannot be C
public class Test{ compiled, because the statement
int x; x++ must be placed inside a
static {x++;} method or a constructor.
} B: When you construct an instance
of Test, the value of x becomes 0.
C: The program cannot be
compiled, because x is non-static,
but is used in a static initialization
block.
D: When you construct an instance
of Test, the value of x becomes 1.

Infoway Technologies Pvt. Ltd., Pune Page 32 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.63 Which of the following statement is A: If a class has any abstract B
false? methods it must be declared
abstract itself.
B: All methods in an abstract class
must be declared as abstract
C: When applied to a class, the
final modifier means it cannot be
sub-classed
D: transient and volatile are Java
modifiers
Q.No.64 If you will run following code what A: hello throw it caught finally after A
will be the result? B: hello throw it RuntimeException
public class RTExcept { caught after
public static void throwit () { C: Compilation fails
System.out.print("throw it "); D: hello throw it caught finally after
throw new RuntimeException(); RuntimeException
}
public static void main(String [] args) {
try {
System.out.print("hello ");
throwit();
}
catch (Exception re ) {
System.out.print("caught ");
}
finally {
System.out.print("finally ");
}
System.out.println("after ");
}
}

Q.No.65 Which of the following statements A: The instanceof operator can be B


are true? used to determine if a reference is
an instance of a class, but not an
interface.
B: The instanceof operator can be
used to determine if a reference is
an instance of a particular primitive
wrapper class
C: 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
D: The instanceof operator can be
used to determine if one reference
is of the same class as another
reference thus

Infoway Technologies Pvt. Ltd., Pune Page 33 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.66 Which collection class allows you A: java.util.SortedMap D
to access its B: java.util.TreeMap
elements by associating a key with an C: java.util.TreeSet
element’s D: java.util.HashTable
value, and provides synchronization?
Q.No.67 which statement is wrong? A: you can extend an interface C
B: you can define a variable inside
an Interface.
C: You can implement interface to
interface.
D: Interface is pure abstract class
Q.No.68 Which one is true about interface A: Abstract class can have only C
and abstract instance method and default
class? behavior. Interface can declare
constants and can have instance
method but cannot implements
default behavior.
B: An interface has all public
members and abstract class has
private, protected etc members
C: Both 1 & 2
D: None of the above
Q.No.69 What access control keyword A: public D
should you use to allow other classes to B: protected
access a method freely within its package, C: private
but to restrict classes outside of the D: do not supply an access control
package from accessing that method? keyword
Q.No.70 Objects are passed by value or A: By value A
reference? B: By reference
C: It depends upon how you
specify
D: None of the above

Q.No.71 exception might wait() throw? A: InterruptedException or A


__________ IllegalMonitorException
B: NoMethodFoundException
C: WaitiingException
D: OutOfBoundException

Q.No.72 If you write System.exit(0) at the A: Yes B


end of try block, will the finally block still B: No
execute? C: It depends upon return
statement
D: Can’t say

Infoway Technologies Pvt. Ltd., Pune Page 34 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.73 Given this code snippet: A: Nothing C
try { B: "exception 1", followed by
tryThis(); "finally"
return; C: "exception 2", followed by
} catch (IOException x1) { "finally"
System.out.println("exception 1"); D: "exception 1"
return;
} catch (Exception x2) {
System.out.println("exception 2");
return;
} finally {
System.out.println("finally");
}
What will appear in the standard output if
tryThis() throws a
NumberFormatException?
Q.No.74 Which is a keyword? A: string D
B: unsigned
C: Float
D: this

Q.No.75 Which is not a method of object A: toString D


class B: clone
C: equals
D: compare
Q.No.76 Which is valid declaration of a A: String s2 = ‘null’; c
String? B: String s3 = (String) ‘abc’;
C: String s1 = null;
D: String s4 = (String) ‘\ufeed’

Q.No.77 How many abs methods are A: 1 D


present in math class. B: 2
C: 3
D: 4

Q.No.78 Which is valid declaration within A: public static short stop = 23 A


an interface? B: protected short stop = 23
C: transient short stop = 23;
D: final void madness(short stop);

Q.No.79 Which interface does A: Java.util.Map A


java.util.Hashtable implement? B: Java.util.List
C: Java.util.HashTable
D: Java.util.Collection

Q.No.80 class Equals{ A: true C


public static void main(String[] args){ B: false
int x= 100; C: Compilation fails
double y = 100.1; D: An exception is thrown at

Infoway Technologies Pvt. Ltd., Pune Page 35 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Boolean b = (x=y); runtime
System.out.println(b);
}
}
Q.No.81 which exception is thrown when A: EmptyStackException A
stack is empty B: StackEmptyException
C: ISEmptyException
D: None of above
Q.No.82 Line 1. long test(int x, float y) A: return x; B
Line 2. { B: return (long) x/y
Line 3. C: return(int) 3.14d
Line 4. } D: return (long)y;
The above program will not compile by
inserting which of the following line?
Q.No.83 Suppose that you would like to A: TreeMap C
create an instance of a new Map that has B: HashMap
an iteration order that is the same as the C: LinkedHashMap
iteration order of an existing instance of D: The answer depends on the
a Map. Which concrete implementation of implementation of the existing
the Map interface should be used for the instance.
new instance?

Q.No.84 Which statement is true about A: if x and y refer to instances of D


wrapper or String classes? different wrapper classes, then the
fragment x.equals(y) will cause a
compiler failure.
B: if x and y refer to instances of
different wrapper classes, then
x==y can sometimes be true.
C: If x and y are String references
and if x.equals(y) is true, then x==y
is true.
D: If x,y and z refer to instances of
wrapper classes and x.equals(y) is
true, and y.equals(z) is true, then
z.equals(x) will always be true.
Q.No.85 Which collection class allows you A: java.util.HashSet D
to grow or shrink its size and provides B: java.util.LinkedHashSet
indexed access to its elements, but whose C: java.util.List
methods are not synchronized? D: java.util.ArrayList

Q.No.86 String x = “xyz”; A: abcXyz C


x.toUpperCase(); B: abcxyz
String y = x.replace(‘Y’,‘y’); C: xyzabc
y = y + “abc” ; D: compilation fails
System.out.println(y); What is the result?

Infoway Technologies Pvt. Ltd., Pune Page 36 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.87 Given this class definitions: A: This code will not compile C
abstract class Transaction implements because the parameter i is not
Runnable { } used in undo().
class Deposit extends Transaction { B: This code will not compile
protected void process() { because there is no main()
addAmount(); method.
} C: This code will not compile
void undo(int i) { because Deposit must be an
System.out.println("Undo"); abstract class.
} D: This code will not compile
} because Deposit is not declared
What will happen if we attempted to public.
compile the code?

Q.No.88 String a = “newspaper”; A: apa B


a = a + b; B: app
char b = a.charAt(1); C: apea
a = a + b; D: apep
System.out.println(a); What is the result?
Q.No.89 If you supply a target object when A: targetObject instanceof Thread D
you create a new Thread, as in: B: targetObject instanceof Object
Thread t = new Thread(targetObject); C: targetObject instanceof Applet
What test of instanceof does targetObject D: targetObject instanceof
have to pass for this to be legal? Runnable

Q.No.90 public class SqrtExample{ A: 3.0 C


public static void main(String [] args){ B: –3.0
double value = -9.0; C: NaN
System.out.println(Math.sqrt(value)); D: Compilation fails
}
}
Q.No.91 How can you serialize an object? A: You have to make the class of A
the object implement the interface
Serializable.
B: You must call the method
serializeObject() (which is inherited
from class Object) on the object.
C: You should call the static
method serialize(Object obj) from
class Serializer, with as argument
the object to be serialized.
D: You don’t have to do anything,
because all objects are serializable
by default
Q.No.92. What will happen when you A: Compile time error A
attempt to compile and run the following B: Compilation and output of
code Claines 99
C: Compilation and output of
class Base Claines 1
{ D: Compilation and not output at
Infoway Technologies Pvt. Ltd., Pune Page 37 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
protected int i = 99; runtime
}
public class Ab
{
private int i=1;
public static void main(String
argv[])
{
Ab a = new Ab();
a.hallow();
}
abstract void hallow()
{

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

Infoway Technologies Pvt. Ltd., Pune Page 38 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Window Toolkit
C: You cannot place AWT
components on Swing containers.
D: The AWT classes are
deprecated
Q.No.96 An Action Event which method A: public Component getClass() B
allows you to identify the affected B: pubilc Object getSource()
Component? C: public Component getSource()
D: public component getTarget()

Q.No.97 Which of the following statements A: Event objects are placed on a C


about events are correct? Queue, where they are fetched by
subscribers (objects of classes
which implement the interface
Subscriber).
B: The listener of an event must
implement the method public void
listen(EventObject obj).
C: Each event object must be an
object of a subclass of
EventObject.
D: Each event listener cannot
investigate about the source of an
event by calling the method
getSource() on the event object.
Q.No.98 What will happen when you A: Derived.amethod() B
attempt to compile and run the following -1
code? Derived.amethod()
class Base { B: Derived amethod()
int i = 99; 99
public void amethod(){ Derived.amethod()
System.out.println("Base.amethod()"); C: 99
} Derived.amethod()
Base(){ D: Compile time error
amethod();
}
}
public class Derived extends Base{
int i = -1;
public static void main(String argv[]){
Base b = new Derived();
System.out.println(b.i);
b.amethod();
}
public void amethod(){
System.out.println("Derived.amethod()");
}
}

Infoway Technologies Pvt. Ltd., Pune Page 39 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.99 Which of the following is a valid A: <applet class=Test.class C
way to embed an applet class named “Test” width=100 height=100>
into a Web page? </applet>
Select all right answers. B: <applet code=Test width=100
height=100>
</applet>
C: <applet code=Test.class
width=100 height=100>
</applet>
D: <applet param=Test.class
width=100 height=100>
</applet>
Q.No.100 What will be printed when you A: Z D
execute the following code? B: YZ
C: XYZ
class X { D: YXYZ
Y b = new Y();
X() {
System.out.print("X");
}
}
class Y {
Y() {
System.out.print("Y");
}
}
public class Z extends X {
Y y = new Y();
Z() {
System.out.print("Z");
}
public static void main(String[] args) {
new Z();
}
}
Q.No.101 The setForeground() and A: Graphics C
setBackground() methods are defined in B: Container
class: C: Component
Select the one right answer. D: Applet

Q.No.102 What will be the output on A: Compilation Error D


compiling/running the following code? B: Prints : Yes Yes Yes Yes Yes
Yes Yes Yes Yes Yes and so on.
public class MyThread implements C: Prints : No No No No No No No
Runnable { No No No and so on
String myString = "Yes "; D: The Output cannot be
public void run() { determined.
this.myString = "No ";
}
public static void main(String[] args) {
Infoway Technologies Pvt. Ltd., Pune Page 40 of 93
Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
MyThread t = new MyThread();
new Thread(t).start();
for (int i=0; i < 10; i++)
System.out.print(t.myString);
}
}
Q.No.103 Which of the following features is A: Multithreading C
not supported by Java? B: Reflection
C: Operator Overloading
D: Garbage Collection (GC)

Q.No.104 Which of the following statements A: static methods do not have C


are true? access to the implicit variable
called this
B: A static method may be called
without creating an instance of its
class
C: All of Above
D: Non of Above

Q.No.105 Which package to import while A: import java.lang.reflect.* A


using reflection in java? B: import java.lang.reflection.*
C: import java.reflect.*;
D: None of the above
Q.No.106 What results from attempting to A: prints: Value is – 9 D
compile and run the following code? B: prints: Value is – 5
public class Ternary C: Compilation error
{ D: None of these
public static void main(String args[])
{
int a = 5;
System.out.println("Value is -
" + ((a < 5) ? 9.9 : 9));
}
}

Q.No.107 Methos of ServerSocket class A: IOException A


throws B: FileException
C: NoServerFoundException
D: None of above

Q.No.108 Given the code below, and A: private or nothing(i.e. leaving it A


making no other changes, which access as it is) on line 3. Nothing(i.e.
modifiers (public, protected or private) can leaving it as it is) or protected or
legally be placed before myMethod() on line public on line 8.
3? If line 3 is left as it is, which keywords B: public or protected on line 3.
can legally be placed before myMethod on private or nothing(i.e. leaving it as
line 8? it is) on line 8.
C: nothing(i.e. leaving it as it is) or

Infoway Technologies Pvt. Ltd., Pune Page 41 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
1. class HumptyDumpty protected or public on line 3.
2. { private or nothing(i.e. leaving it as
3. void myMethod() {} it is) on line 8.
4. } D: None of the above
5.
6. class HankyPanky extends
HumptyDumpty
7. {
8. void myMethod() {}
8. }
Q.No.109 Remote interface has ---- A: 1 D
methods B: 2
C: 3
D: None of the above

Q.No.110 Which of the following are A: run A


methods of the Runnable interface B: start
C: yield
D: stop
Q.No.111 Which is not a type of pattern? A: Creational Patterns D
B: Structural Patterns
C: Behavioral Patterns
D: Artificial Patterns
Q.No.112 Considering the following code, A: a,b,c,e A
Which variables may be referenced B: a,b,c,d,e
correctly at line 12? C: a,c,d,e
1. public class Outer D: e
2. {
3. public int a = 1;
4. private int b = 2;
5. public void method(final int c)
6. {
7. int d = 3;
8. class Inner
9. {
10. private void
iMethod(int e)
11. {
12.
13. }
14. }
15. }
16. }
Q.No.113 Which design pattern you would A: Factory Method Design Pattern D
you use to limit the class instantiation to B: Builder design pattern
one object? C: Prototype design pattern
D: Singleton design pattern

Infoway Technologies Pvt. Ltd., Pune Page 42 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.114 If MyProg.java were compiled as A: MyProg C
an application and then run from the B: "I"
command line as: C: "like"
java MyProg I like tests D: 3
what would be the value of args[1] inside
the main() method?
Q.No.115 There are a number of labels in A: d: A
the source code below. These are labeled a B: e:
through j. Which label identifies the earliest C: h:
point where, after that line has executed, D: i:
the object referred to by the variable first
may be garbage collected?
class Riddle
{
public static void main(String[] args)
{
String first, second;
String riddle;
if (args.length < 2)
return;
a: first = new String(args[0]);
b: second = new
String(args[1]);
c: riddle = "When is a " + first;
d: first = null;
e: riddle += " like a " + second
+ "?";
f: second = null;
g: System.out.println(riddle);
h: args[0] = null;
i: args[1] = null;
j:
}
}
Q.No.116 Predict the Output: A: 1 A
public class test { B: 2
public static void main(String args[]) { C: 3
boolean x = true; D: 4
int a;
if(x)
a = x ? 1: 2;
else
a = x ? 3: 4;
System.out.println(a);
}
}

Infoway Technologies Pvt. Ltd., Pune Page 43 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.117 What are the ranges of values for A: -27 to 27 - 1 D
a variable of type byte? B: 0 to 27
Select the one right answer. C: -215 to 215
D: -215 to 215 -1
Q.No.118 public class test { A: 1 D
public static void main(String args[]) { B: 2
boolean x = false; C: 3
int a; D: 4
if(x) a = x ? 1: 2;
else a = x ? 3: 4;
System.out.println(a);
}
}

Q.No.119 : What is the result of invoking A: D: equal; E: equal C


main() for the classes D and E? B: D: not equal; E: not equal
class D { C: D: equal; E: not equal
public static void main(String[] args) { D: D: not equal; E: not equal
String s1 = new String("hello");
String s2 = new String("hello");
if (s1.equals(s2))
System.out.println("equal");
else
System.out.println("not equal");
}
}
class E {
public static void main(String[] args) {
StringBuffer sb1 = new StringBuffer("hello");
StringBuffer sb2 = new StringBuffer("hello");
if (sb1.equals(sb2))
System.out.println("equal");
else
System.out.println("not equal");
}
}

Q.No.120 Predict the output A: 5 B


public class test { B: 0
public static void main(String args[]) { C: 80
int x, y; D: 2
x = 5 >> 2;
y = x >>> 2;
System.out.println(y);
}
}

Infoway Technologies Pvt. Ltd., Pune Page 44 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q.No.121 What does the following code do A: draw a line from x = 0, y = 20 to B
(if anything)? x = 10, y = 30
drawLine(0, 10, 20, 30); B: draw a line from x = 0, y = 10 to
the coordinates x = 20, y = 30
C: draw the outline of a box whose
left, top corner is at 0, 10 and that
is 20 pixels wide and 30 pixels
high
D: nothing—this code does not
compile because it does not
provide the correct number of
arguments
Q.No.122 Predict the output A: The program prints 0 C
public class test { B: The program prints 1
public static void main(String args[]) { C: The program does not compile
int x = 0, y = 1, z; because of problems in the if
if(x) statement.
z = 0; D: The program prints 3
else
z = 1;
if(y)
z = 2;
else
z = 3;
System.out.println(z);
}
}

Q.No.123 After these two lines of code: A: "Dolly Hello, " B


B: "Hello, "
String s = "Dolly "; C: "Dolly "
String t = s.concat("Hello, "); D: none of the above
What characters will the object reference t
contain?
Select the one right answer.
"Hello, Dolly "
Q.No.124 What is the return type of the A: int C
method getSource() defined in EventObject B: long
class. Select the one correct answer. C: Object
D: Component
Q.No.125 Which label name is illegal? A: here: C
B: _there:
C: this:
D: that:

Q.No.126 Which method identifies the type A: getSource() D


of an event generated. Select the one B: getType()
correct answer. C: getEventType()
D: getID()

Infoway Technologies Pvt. Ltd., Pune Page 45 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

Q.No.127 : Given these class definitions: A: Illegal at compile time A


B: Legal at compile time but
class Superclass { } possibly illegal at runtime
class Subclass1 extends Superclass { } C: Definitely legal at runtime
class Subclass2 extends Superclass { } D: none of the above
and these objects:
Superclass a = new Superclass();
Subclass1 b = new Subclass1();
Subclass2 c = new Subclass2();
which of the following explains the result of
the statement:
b = (Subclass1)c;
Q.No.128 Name the class used to A: Window D
represent a GUI application window, which B: Panel
is optionaly resizable and can have a title C: Dialog
bar, an icon, and menus. Select the one D: Frame
correct answer.
Q.No.129 Which operators are overloaded A: -> C
for String objects? B: -
C: + and +=
D: none
Q.No.130 Which class can be used to A: MenuBar C
represent a checkbox with a textual label B: MenuItem
that can appear in a menu? Select the one C: CheckBoxMenuItem
correct answer. D: Menu

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?

Infoway Technologies Pvt. Ltd., Pune Page 47 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Answer Choices
A: An application can in general be trusted whereas an applet can't.
B: An applet must be executed in a browser environment.
C: An applet is not able to access the files of the computer it runs on
D: (A),(B)and(C).

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

Infoway Technologies Pvt. Ltd., Pune Page 48 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Answer Choices
A: False B: True
C: Ambiguous Statement D: none of the above

Q.No 140.
Question:

public class MyOuter


{
public static class MyInner
{
public static void foo() { }
}
}
which statement, if placed in a class other than MyOuter or MyInner, instantiates an instance
of the nested class?

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:

Infoway Technologies Pvt. Ltd., Pune Page 49 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
What will be the output of the program?
class A
{
final public int GetResult(int a, int b) { return 0; }
}
class B extends A
{
public int GetResult(int a, int b) {return 1; }
}
public class Test
{
public static void main(String args[])
{
B b = new B();
System.out.println("x = " + b.GetResult(0, 1));
}
}

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)
{

Infoway Technologies Pvt. Ltd., Pune Page 50 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
try
{
System.out.print("hello ");
throwit();
}
catch (Exception re )
{
System.out.print("caught ");
}
finally
{
System.out.print("finally ");
}
System.out.println("after ");
}
}

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.

Infoway Technologies Pvt. Ltd., Pune Page 51 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Question:
What is the value of "d" after this line of code has been executed?
double d = Math.round ( 2.5 + Math.random() );

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

Infoway Technologies Pvt. Ltd., Pune Page 52 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Question:
What are a native methods?

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

Infoway Technologies Pvt. Ltd., Pune Page 53 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
C: java.util.HashMap D: java.util.TreeMap

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 [])

Infoway Technologies Pvt. Ltd., Pune Page 54 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
{
MyVector v = new MyNewVector(); /* Line 19 */
}
}

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?

Infoway Technologies Pvt. Ltd., Pune Page 55 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Answer Choices
A: set() B: make() C: setPriority() D: makePriority()

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

Infoway Technologies Pvt. Ltd., Pune Page 56 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
C: File Filtering D: All of the mentioned

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

Infoway Technologies Pvt. Ltd., Pune Page 57 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
30. class Myclass implements Serializable {
31. String s;
32. int i;
33. double d;
34. Myclass (String s, int i, double d){
35. this.d = d;
36. this.i = i;
37. this.s = s;
38. }
39. }

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.

Infoway Technologies Pvt. Ltd., Pune Page 58 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Question:
Which method executes only once

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

Infoway Technologies Pvt. Ltd., Pune Page 59 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

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

Infoway Technologies Pvt. Ltd., Pune Page 60 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

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

Infoway Technologies Pvt. Ltd., Pune Page 61 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Answer Choices
A: 0 B: 1 C: true D: false

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

Difficulty Level: Easy

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

Difficulty Level: Easy

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:

Infoway Technologies Pvt. Ltd., Pune Page 62 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Which of the following is a Java primitive type?
Answer Choices
A: int B: String
C: Integer D: Boolean

Difficulty Level: Easy

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

Difficulty Level: Intermediate

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

Infoway Technologies Pvt. Ltd., Pune Page 63 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

Difficulty Level: Easy

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

Infoway Technologies Pvt. Ltd., Pune Page 64 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Question:
Which of these coding types is used for data type characters in Java?
Answer Choices
A: ASCII B: ISO LATIN
C: UNICODE D: None of the above
Difficulty Level: Intermediate

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

Difficulty Level: Easy

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

Difficulty Level: Easy

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

Infoway Technologies Pvt. Ltd., Pune Page 65 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

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

Difficulty Level: Easy

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

Difficulty Level: Intermediate

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

Infoway Technologies Pvt. Ltd., Pune Page 66 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

Difficulty Level: Easy

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

Difficulty Level: Intermediate

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

Difficulty Level: Easy

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

Difficulty Level: Easy

Q. No. 195
Question:
Which of the following can be used to run an applet?
Answer Choices
A: Appletviewer B: Browser

Infoway Technologies Pvt. Ltd., Pune Page 67 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
C: Java command D: Both A and B

Difficulty Level: Easy

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

Difficulty Level: Intermediate

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

Difficulty Level: Easy

Q. No. 198
Question:
What is the Listener for Button Click in Swing?
Answer Choices
A: ButtonListener B: ActionListener
C: WindowListener D: MouseListener

Difficulty Level: Easy

Q. No. 199
Question:
What is the Listener for Mouse Click in Swing?
Answer Choices
A: ButtonListener B: ActionListener
C: WindowListener D: MouseListener

Infoway Technologies Pvt. Ltd., Pune Page 68 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Difficulty Level: Easy

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

Difficulty Level: Easy

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

Difficulty Level: Easy

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

Difficulty Level: Easy

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

Difficulty Level: Easy

Infoway Technologies Pvt. Ltd., Pune Page 69 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

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

Difficulty Level: Easy

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

Difficulty Level: Intermediate


Q. No. 206
Question:
Which of these methods returns the class of an object?
Answer Choices
A: getClass B: Class
C: newClass D: All the above

Difficulty Level: Easy

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

Difficulty Level: Difficult

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

Difficulty Level: Easy

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

Difficulty Level: Intermediate

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

Difficulty Level: Intermediate

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

Infoway Technologies Pvt. Ltd., Pune Page 72 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Difficulty Level: Difficult

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

Difficulty Level: Easy

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

Infoway Technologies Pvt. Ltd., Pune Page 73 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
A: static B: final
C: static and final D: abstract

Difficulty Level: Easy

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

Difficulty Level: Easy

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

Difficulty Level: Easy


Q. No. 218
Question:
Which of these keywords cannot be used for a class which has been declared final?
Answer Choices
A: abstract B: public
C: Both A and B D: None of the above

Difficulty Level: Easy

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

Difficulty Level: Intermediate

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

Difficulty Level: Intermediate

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

Difficulty Level: Easy

Q. No. 222

Infoway Technologies Pvt. Ltd., Pune Page 75 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Question:
How does the readObject method of ObjectInputStream indicate the end of file?
Answer Choices
A: Returns null B: Returns -1
C: Throws EOFException D: Closes automatically

Difficulty Level: Difficult

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

Infoway Technologies Pvt. Ltd., Pune Page 77 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Correct Answer: B

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

Infoway Technologies Pvt. Ltd., Pune Page 78 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Difficulty Level: Intermediate
Correct Answer: A

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.

Infoway Technologies Pvt. Ltd., Pune Page 79 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
D. A class can extend only one class and implement many interfaces.
Difficulty Level: Easy
Correct Answer: D

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

Infoway Technologies Pvt. Ltd., Pune Page 80 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q. No. 236
Question:
class A{
public void doA(){
B b = new B();
b.dobB();
System.out.print("doA");
}
}
class B{
public void dobB(){
C c = new C();
c.doC();
System.out.print("doB");
}
}
class C{
public void doC(){
if(true)
throw new NullPointerException();
System.out.print("doC");
}
}
public class Test{
public static void main(String args[]){
try{
A a = new A();
a.doA();
}catch(Exception ex){
System.out.print("error");
}
}
}
Answer Choices
A. “doCdoBdoA” is printed
B. “doAdoBdoC” is printed
C. “doBdoAerror” is printed.
D. “error” is printed.
Difficulty Level: Easy
Correct Answer: D

Q. No. 237
Question:
String objects are stored in special memory area known as?

Infoway Technologies Pvt. Ltd., Pune Page 81 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Answer Choices:
A. Heap
B. Stack
C. String Constant Pool
D. Memory Area
Difficulty Level: Easy
Correct Answer: C

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

Infoway Technologies Pvt. Ltd., Pune Page 82 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Question:
Each element must be unique
Duplicate elements must not replace old elements.
Elements are not key/value pairs.
Accessing an element can be almost as fast as performing a similar operation on an array.
Which of these classes provide the specified features?
Answer Choices
A. HashSet
B. HashMap
C. TreeMap
D. LinkedList
Difficulty Level: Easy
Correct Answer: A

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

Difficulty Level: Easy

Infoway Technologies Pvt. Ltd., Pune Page 83 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Correct Answer: A

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

public class Test{


public static void main(String argv[]) throws Exception{
A a = new A();
Thread t = new Thread(a, "A");
Thread t1 = new Thread(a, "B");
t.start();
t.join();
t1.start();
}
}
Answer Choices
A. A A A A B B B B
B. A B A B A B A B
C. Output order is not guaranteed.
D. Compilation succeed but Runtime Exception
Difficulty Level: Intermediate
Correct Answer: A

Q. No. 247
Question:
What does notifyAll() method do?
Answer Choices:
A. Wakes up all threads that are waiting on this object’s monitor

Infoway Technologies Pvt. Ltd., Pune Page 85 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
B. Wakes up one thread that are waiting on this object’s monitor
C. Wakes up all threads that are not waiting on this object’s monitor
D. None of the above.
Difficulty Level: Easy
Correct Answer: A

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

Infoway Technologies Pvt. Ltd., Pune Page 86 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q. No. 250
Question:
When comparing java.io.BufferedWriter and java.io.FileWriter, which capability exist as a
method in only one of two ?
Answer Choices
A. Closing the stream
B. Flushing the stream
C. Writing to the stream
D. Writing a line separator to the stream
Difficulty Level: Intermediate
Correct Answer: D

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

Infoway Technologies Pvt. Ltd., Pune Page 87 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
Q. No. 253
Question
Which is used to store data and partial results, as well as to perform dynamic linking, return
values for methods, and dispatch exceptions?

Answer Choice:
A. Window
B. Panel
C. Frame
D. Container

Difficulty Level: Intermediate


Correct Answer: C

Q. No. 254

Question

Which of these methods can be used to know which key is pressed?


Answer Choice:
A. getActionEvent()
B. getActionKey()
C. getModifier()
D. getKey()
Difficulty Level: Easy
Correct Answer: C

Module: Session No. 20


Q. No. 255
Question:
The following specifies the advantages of
It is lightweight.
It supports pluggable look and feel.
It follows MVC (Model View Controller) architecture.
Answer Choices:
A. Swing
B. AWT
C. Both A and B
D. None of the above.
Difficulty Level: Easy
Correct Answer: A

Infoway Technologies Pvt. Ltd., Pune Page 88 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

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()

Infoway Technologies Pvt. Ltd., Pune Page 89 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
B. run()
C. init()
D. paint()
Difficulty Level: Easy
Correct Answer: C

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

Infoway Technologies Pvt. Ltd., Pune Page 90 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I
C. Java.lang.reflect.ReflectPermission
D. Java.lang.reflect.Execuatble
Difficulty Level: Easy
Correct Answer: B

Q. No. 262
Question:
import java.lang.reflect.Method;
class Demo{
private int x;
private int y;

public Demo(int x, int y) {


super();
this.x = x;
this.y = y;
}

public void display() {


System.out.println( "Demo [x=" + x + ", y=" + y + "]");
}
}

public class ReflectDemo {

public static void main(String[] args) {


try{
Class c=Class.forName("Demo");
Demo d=(Demo)c.newInstance();
d.display();
}catch(Exception e){
System.out.println("Something's going wrong............");
}

}
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

Infoway Technologies Pvt. Ltd., Pune Page 91 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

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

Infoway Technologies Pvt. Ltd., Pune Page 92 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com
Java Technologies I

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

Infoway Technologies Pvt. Ltd., Pune Page 93 of 93


Contact No.: 020-41312111/12
Website: www.infowayltd.com

You might also like