A1. Which of the following is a legal identifier in java ? 1. 2variable
2. #myvar
3. +@$var
4. $_myvar
Which of these is NOT valid keyword or reserved word in Java ? A2.
A3.
1. default
2. null
3. String
4. volatile
Which is the legal range of values for a short ?
1. -128 to 127
2. -256 to 255
3. -32768 to 32767
4. 0 to 65535
A5.
Which of the following Array Array declaration statement is ilegal ? 1. int [ ] a [ ] = new int [4] [4];
2. int a[ ][ ] = new int [4] [4];
3. int a[ ] [ ] = new int [ ] [4];
4. int [ ] a [ ] = new int [4] [ ];
A6. What
will haen if you try to comile and run the following
code ? public class Test { public static void main(String argv[]) { int[] arr ne! int[]{"#2#3$%
S&stem.out.println(arr["])% $
$
1. 1
2. Error: Error: arr is is reer reeren!e en!e" " beore beore it it is initialie"
3. 2
4. Error: sie o array mst be "eine"
A'. !n
the given Array declaration" which e#ression returns the outut as $ ? int [] arr { 23# 5# '# 3# 2
%$1. arr.len%t&'(
2. arr[].len%t&'(
3. arr[].len%t&
4. arr.len%t&
A. What
will %e the outut uon the e#ecution of the following
code ? public class Test { public static void main(String[] args) { int * 5% +or (int i ,% i- *% i) { i+ ( i - *// ) S&stem.out.print( (i0*) 1 1)% $ $ $
A.
1. ) 3 2
2. 1 2 3
3. ) 3 4
4. 1 4 2
Which declaration of the main&' method is valid ? 1. *bli! voi" main' trin% ar%s [] (
2. *bli! voi" stati! main' trin% ar%s [] (
3. inal *bli! stati! voi" main'trin% []arr(
4. *bli! stati! voi" main' trin% []arr(
A",. Which
one of the following is invalid declarations of a char ?
1. !&ar !1 = ),4--);
2. !&ar !2 = a!e;
3. !&ar !3 = )/bee;
4. !&ar !, = 0a!e;
A"".
What will %e the outut of the following code ?
public static void main(String[] args) { double d ",,.,% oat + d% S&stem.out.println(14loat value 1+)% $
1. 1)).)4
2. 1)).)
3. !om*ilation error
4. 1))
A"2. Which
is true ?
1. e/ten"s is !orre!t i an" only i is a !lass an" is an intera!e. 2. e/ten"s is !orre!t i an" only i is a intera!e an" is a !lass. 3. e/ten"s is !orre!t i an" are eit&er bot& !lasses or bot& intera!e. 4. e/ten"s is !orre!t or all !ombinations o an" bein% !lasses an"or intera!es.
A"3. which
is not a valid statement %ased on given code ?
class A{$ class etends A{$
1. 5 a = new 5'(;
2. 6 a = new 6'(;
3. 5 a = new 6'(;
4. 6 b = new 5'(;
What can %e said a%out the statement given code? A".
// Class declarations : class Super {$ class Sub etends Super {$
y = (Sub) x"
%ased on
// Reference declarations : Super % Sub &%
1. 7lle%al at !om*ile time. 2. 8e%al at !om*ile time9 bt mi%&t be ille%al at rntime. 3. einitely le%al at rntime9 bt t&e !ast o*erator 'b( is not stri!tly nee"e". 4. einitely le%al at rntime9 an" t&e !ast o*erator 'b( is nee"e". A"5.
Which letters will %e rinted when the given rogram is run ?
public class 7&8lass { public static void main(String[] args) { b ne! 8()% A a b% i+ (a instanceo+ A) S&stem.out.println(1A1)% i+ (a instanceo+ ) S&stem.out.println(11)% i+ (a instanceo+ 8) S&stem.out.println(181)% i+ (a instanceo+ 9) S&stem.out.println(191)% $ $
class A {$ class etends A {$ class 8 etends {$ class 9 etends 8 {$
1. 59 69 will be *rinte".
2. only 5 an" 6 will be *rinte".
3. only 6 will be *rinte".
4. only will be *rinte".
A"6. What
will %e the Outut ?
class Animal { String name 1animal1% String ma:e;oise() { return 1generic noise1% $ $ class 9og etends Animal { String name 1dog1% String ma:e;oise() { return 1bar:1% $ $ public class Test { public static void main(String[] args) { Animal an ne! 9og()% S&stem.out.println(an.name1 1an.ma:e;oise())% $ $
1. animal %eneri! noise
2. animal bar<
3. "o% bar<
4. "o% %eneri! noise
A"'.
suer keyword in Java is used for ?
1. to reer to imme"iate !&il" !lass o a !lass. 2. to reer to imme"iate *arent !lass o a !lass. 3. to reer to !rrent !lass obe!t. 4. to reer to stati! member o *arent !lass. 51>. (redict
Outut" if the %elow code is run with given command ?
Command Line : *ava m&prog good morning ever&one
public class m&prog { public static void main(String argv[]) { S&stem.out.println(argv["]) $ $
1. my*ro%
2. %oo"
3. mornin%
4. everyone
Which of the given statement is not true a%out an Java (ackage ? A".
1. 5 *a!
)iven two files" what will %e the Outut ?
package pck1; public class A { int ",% public int & 2,% $
package pck2; import pc:".0% class Test { public static void main(String []args)
{ A a ne! A()%
<< line '
S&stem.out.println(a.)%
<< line
S&stem.out.println(a.&)%
<< line
$ $
1. 1) 2)
2. !om*ilation error at line -
3. !om*ilation error at line >
4. !om*ilation error at line A
)iven the following declarations" which assignment is legal ? A2".
<< 8lass declarations = inter+ace A {$ class {$ class 8 etends implements A {$ class 9 implements A {$
<< 9eclaration statements = b ne! ()% 8 c ne! 8()% 9 d ne! 9()%
1. ! = ";
2. " = !;
3. 5 a = ";
4. " = '(!;