Su Swagatam

The Rose flower is for someone special
Please don't touch it.



If u want
S----->Smiling
M----> Magnificient
A---->Awesome
R----> Refreshing
T---->Technical

STUFF

Then U R AT THE RIGHT PLACE


Tuesday, March 8, 2011

Teqnix 2011 Java Paper

The Cradle of Bytes
JAVA Objective Paper
Participant Name:-
College:-
Mobile No:-

1.  public Object m()
{ Object o = new Float(3.14F);
Object [] oa = new Object[l];
oa[0] = o; /* Line 5 */
o = null; /* Line 6 */
oa[0] = null; /* Line 7 */
return o; /* Line 8 */
}
When is the Float object, created in line 3, eligible for garbage collection?
A.
just after line 5
B.
just after line 6
C.
just after line 7
D.
just after line 8

2.  What will be the output of the program?

public class TestDogs
{
public static void main(String [] args)
{
Dog [][] theDogs = new Dog[3][];
System.out.println(theDogs[2][0].toString());
}
}
class Dog { }
A.
Null
B.
theDogs
C.
Compilation fails
D.
An exception is thrown at runtime

3.  What will be the output of the program ?
public class Test
{
public static void main(String [] args)
{
signed int x = 10;
for (int y=0; y<5; y++, x--)
System.out.print(x + ", ");
}
}
A.
10, 9, 8, 7, 6,
B.
9, 8, 7, 6, 5,
C.
Compilation fails.
D.
An exception is thrown at runtime.

4.  Which one of the following will declare an array and initialize it with five numbers?
A.
Array a = new Array(5);
B.
int [] a = {23,22,21,20,19};
C.
int a [] = new int(5);
D.
int [5] array;

5.  Which three are valid declarations of a float?
1.float f1 = -343;
2.float f2 = 3.14;
3.float f3 = 0x12345;
4.float f4 = 42e7;
5.float f5 = 2001.0D;
6.float f6 = 2.81F;
A.
1, 2, 4
B.
2, 3, 5
C.
1, 3, 6
D.
2, 4, 6

6.  What will be the output of the program?
int i = l, j = -1;
switch (i)
{
case 0, 1: j = 1; /* Line 4 */
case 2: j = 2;
default: j = 0;
}
System.out.println("j = " + j);
A.
j = -1
B.
j = 0
C.
j = 1
D.
Compilation fails.

7.  What will be the output of the program?
int i = 1, j = 10;
do
{
if(i > j)
{
break;
}
j--;
} while (++i < 5);
System.out.println("i = " + i + " and j = " + j);
A.
i = 6 and j = 5
B.
i = 5 and j = 5
C.
i = 6 and j = 4
D.
i = 5 and j = 6

8.  What will be the output of the program?
int x = 1, y = 6;
while (y--)
{
x++;
}
System.out.println("x = " + x +" y = " + y);
A.
x = 6 y = 0
B.
x = 7 y = 0
C.
x = 6 y = -1
D.
Compilation fails.

9.  What will be the output of the program?
int I = 0;
outer:
while (true)
{
I++;
inner:
for (int j = 0; j < 10; j++)
{
I += j;
if (j == 3)
continue inner;
break outer;
}
continue outer;
}
System.out.println(I);
A.
1
B.
2
C.
3
D.
4

10.  What will be the output of the program?
int I = 0;
label:
if (I < 2) {
System.out.print("I is " + I);
I++;
continue label;
}
A.
I is 0
B.
I is 0 I is 1
C.
Compilation fails.
D.
None of the above

11.  class Foo
{
class Bar{ }
}
class Test
{
public static void main (String [] args)
{
Foo f = new Foo();
/* Line 10: Missing statement ? */
}
}
which statement, inserted at line 10, creates an instance of Bar?
A.
Foo.Bar b = new Foo.Bar();
B.
Foo.Bar b = f.new Bar();
C.
Bar b = new f.Bar();
D.
Bar b = f.new Bar();

12  What will be the output of the program?
public class Test
{
public static void main(String[] args)
{
int x = 0;
assert (x > 0) ? "assertion failed" : "assertion passed" ;
System.out.println("finished");
}
}
A.
finished
B.
Compiliation fails.
C.
An AssertionError is thrown and finished is output.
D.
An AssertionError is thrown with the message "assertion failed."

13.  public class Test { }
What is the prototype of the default constructor?
A.
Test( )
B.
Test(void)
C.
public Test( )
D.
public Test(void)


14.What will be the output of the program?
try
{
int x = 0;
int y = 5 / x;
}
catch (Exception e)
{
System.out.println("Exception");
}
catch (ArithmeticException ae)
{
System.out.println(" Arithmetic Exception");
}
System.out.println("finished");
A.
Finished
B.
Exception
C.
Compilation fails.
D.
Arithmetic Exception

15.  Which class or interface defines the wait(), notify(),and notifyAll() methods?
A.
Object
B.
Thread
C.
Runnable
D.
Class

16.  public class MyRunnable implements Runnable
{
public void run()
{
// some code here
}
}
which of these will create and start this thread?
A.
new Runnable(MyRunnable).start();
B.
new Thread(MyRunnable).run();
C.
new Thread(new MyRunnable()).start();
D.
new MyRunnable().start();

17.  What will be the output of the program?
class MyThread extends Thread
{
public static void main(String [] args)
{
MyThread t = new MyThread();
t.start();
System.out.print("one. ");
t.start();
System.out.print("two. ");
}
public void run()
{
System.out.print("Thread ");
}
}
A.
Compilation fails
B.
An exception occurs at runtime.
C.
It prints "Thread one. Thread two."
D.
The output cannot be determined.

18.  What will be the output of the program?
class MyThread extends Thread
{
public static void main(String [] args)
{
MyThread t = new MyThread();
Thread x = new Thread(t);
x.start(); /* Line 7 */
}
public void run()
{
for(int i = 0; i < 3; ++i)
{
System.out.print(i + "..");
}
}
}
A.
Compilation fails.
B.
1..2..3..
C.
0..1..2..3..
D.
0..1..2..


19  What will be the output of the program?
String x = new String("xyz");
y = "abc";
x = x + y;
how many String objects have been created?
A.
2
B.
3
C.
4
D.
5


20  What will be the output of the program?
String x = "xyz";
x.toUpperCase(); /* Line 2 */
String y = x.replace('Y', 'y');
y = y + "abc";
System.out.println(y);
A.
abcXyZ
B.
Abcxyz
C.
Xyzabc
D.
XyZabc

21.  What will be the output of the program?
try
{
Float f1 = new Float("3.0");
int x = f1.intValue();
byte b = f1.byteValue();
double d = f1.doubleValue();
System.out.println(x + b + d);
}
catch (NumberFormatException e)
{
System.out.println("bad number");
}
A.
9.0
B.
bad number
C.
Compilation fails on line 13.
D.
Compilation fails on line 14.

22.  What will be the output of the program?
class Q207
{
public static void main(String[] args)
{
int i1 = 5;
int i2 = 6;
String s1 = "7";
System.out.println(i1 + i2 + s1); /* Line 8 */
}
}
A.
18
B.
117
C.
567
D.
Compiler error


23.  What will be the output of the program?
public class StringRef
{
public static void main(String [] args)
{
String s1 = "abc";
String s2 = "def";
String s3 = s2; /* Line 7 */
s2 = "ghi";
System.out.println(s1 + s2 + s3);
}
}
A.
Abcdefghi
B.
Abcdefdef
C.
Abcghidef
D.
Abcghighi

24.  What will be the output of the program?

String a = "ABCD";
String b = a.toLowerCase();
b.replace('a','d');
b.replace('b','c');
System.out.println(b);
A.
abcd
B.
ABCD
C.
Dccd
D.
Dcba

25.  Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
A.
java.lang.String
B.
java.lang.Double
C.
java.lang.StringBuffer
D.
java.lang.Character


java key...............





1.c

2.d

3.c

4.b

5.c

6.d

7.d

8.d

9.a

10.c

------------------------------

11.b

12.b

13.c

14.c

15.a

16.c

17.b

18.d

19.c----

20.c-----

21.a---

22.b-------

23.c

24.a--------

25.c--

No comments:

Post a Comment