You are on page 1of 10

.

Java 6 Test

Duration: 60 Min. 1) a). b). c). d). The base class for Complete java is Class Object Method None

Max Marks: 50

2) The default value for an Object in Java is a) b) c) d) True False Null None of above

) !!!!!!!!!!!! is the "e#$ord to create constants in Java. a) const b) define c) final d) None %) &f Constructor is not defined in the class' the constructor (enerated b# compiler is!!!!! a) )arameteri*ed Constructor b) default Constructor c) Cop# Constructor d) d#namic Constructor +). &n order for a source code file' containin( the public class Test' to successfull# compile' $hich of the follo$in( must be true, a)&t must have a pac"a(e statement b)&t must be named Test.java c)&t must import java.lan( d)&t must declare a public class named Test

- ) One Constructor from .nother Constructor in the same class can be called usin(!!!!!!!!!!! a) super
1 of 10

. b) c) d) final this None

/). class 0tatic&nitialiser1 static1 0#stem.out.print23loadin(3)4 5 5 class 0tatic6loc"7emo1 public static void main20trin( ar(s89)1 0tatic&nitialiser obj:ne$ 0tatic&nitialiser2)4 0tatic&nitialiser obj1:ne$ 0tatic&nitialiser2)4 5 5 ;hat is the output on runnin( this pro(ram, 1 < loadin(loadin( 2 < loadin( < no output % < runtime error =). class .1 public static void main20trin( 89 ar(s) 1 int i4 0#stem.out.println2i)4 5 5 ;hat is the output on processin( the code, 1< 2< < %< >untime error ? 1 compilation error@variable i mi(ht not have been initiali*ed

A) a. b.

.n interface can eBtend Onl# one other interface Onl# one other Class
2 of 10

. c. d. .n# number of classes .n# number of &nterfaces

1?)

Consider the follo$in( code

class . 1 public static void main20trin(89 ar(s) 1 tr#1 &nt a:1?'b:?'B89:11'2' '%54 0#stem.out.println2aCb)4 0#stem.out.println2B8%9)4 5 catch2DBception e) 1 5 catch2.rithmeticDBception e1) 1 5 55 &f #ou compile $hat happens, a) Compiles successfull# b) 7oesnEt compile c) Compiles but runtime eBception d) None 11) .ssi(nin( the &nstance of Child class to the reference of 6ase class is called a) Fpcastin( b) 7o$ncastin( c) Not possible d) Composition

12) .bstract classes cannot be !!!!!!!!!!!!!!! a) Created b) eBtended c ) &nstantiated d)&mplemented 1 ) !!!!!!!!!!!!! Methods cannot be Overriden b# Child class.
3 of 10

. a) static b) public c) final d) .ll the above 21%) class base 1 public base2)1 0#stem.out.println23base3)4 5 static 1 0#stem.out.println23base static3)4 5 5 class child eBtends base 1 static int a4 public child2)1 0#stem.out.println23child3)4 5 static 1 0#stem.out.println23 child static 3)4 5 5 public class 0ample 1 public static void main20trin( ar(s89)1 child.a:%?4 5 5 Output@ a)child child static b) 6ase static child static c) Child static 6ase static d)child static

1+). .ssume the belo$ indicated code chun"s is in 2 seperate files. 1 pac"a(e p14
4 of 10

. 2 public class 0ample 1 protected int "4 % void sho$2) 1 0#stem.out.println2")4 5 5 !!!!!!!!!!!!!!!!!!!!!!!!!!!! + pac"a(e p24 - import p1.G4 / class M#0ample eBtends 0ample1 = void set2) 1 " : 1? 45 A void displa#2) 1 sho$2)4 5 5 0tatement correspondin( to $hich line number causes an error' if .NH, a. / b. = c. A d. there is no error at all 1-). ;hich of the follo$in( methods can be le(all# inserted in place of the comment CCMethod Iere , class 6ase 1 public void aMethod2int i) 1 5 5 public class 0cope eBtends 6ase 1 public static void main20trin( ar(s89) 1 5 CCMethod Iere 5

options@ a). void amethod2int i) thro$s DBception 1 5 b). void amethod2double) thro$s DBception 1 c). void amethod2int i) 1
5 of 10

. 5 d). public void amethod2int i) 1 5 1/). Consider the follo$in( pro(ram@ class 7emo 1 public static void main20trin( ar(s89) 1 int a'd4 int c89:1154 tr# 1 d:ar(s.len(th4 a:%2Cd4 c81/9:1??4 5 catch2.rithmeticDBception arithmeticDBception) 1 0#stem.out.println237ivision b# *ero error3)4 5 catch2.rra#&ndeBOutOf6oundsDBception arra#&ndeBOutOf6oundsDBception) 1 0#stem.out.println23.rra# &ndeB Out of 6ounds3)4 5 catch2DBception eBception) 1 0#stem.out.println23Fn"no$n Drror3)4 5 5 5 . if #ou run the pro(ram as java 7emo $hat is the output@ a) 7ivision b# *ero error b) .rra# &ndeB Out of bounds c). un"no$n error
6 of 10

1=). ;hat are the $a#s of creatin( threads in J.J., i.DBtendin( the java.lan(.Thread class ii.DBtendin( the java.lan(.>unnable class iii.&mplementin( the java.lan(.>unnable interface iv.&mplementin( the java.lan(.Thread interface Options A. B. C. D. @ 2i) K 2iv) 2ii) K 2iii) 2i) K 2iii) 2iv) K 2ii)

1A).
Which of the following is/are TRUE about List Interface? (i) Defines an ordered collection. (ii) Defines a collection that does not allow du licate ele!ents. (iii) The add !ethod returns false if rogra! atte! ts to add a du licate ele!ent. (i") #llows accessing ele!ents b$ their osition and searching ele!ents in the list.

Options @ .. 2i)'2ii)'2iv) 6. 2i)'2iii)'2iv) C. 2i)'2iv) 7. .ll the options. 2?). ;ith reference to the Thread 0tates in J.J. $hich of the follo$in( isCare T>FD, 2i) >FNN.6LD $ait2) ;.&T&NM 2ii) ND; 6O>N start2) >FNN.6LD 2iii) >FNN&NM #ield2) >FNN.6LD 2iv) ;.&T&NM notif#.ll2) >FNN.6LD 2v) >FNN&NM &CO >eNuest 6LOCOD7 Options .. 6. C. 7. @ 2i)'2ii)'2iii)'2v) 2ii)'2iii)'2iv)'2v) 2ii)'2iv)'2v) .ll the options.

7 of 10

. 21). ;hat is the output of the follo$in( code snippet, Note@ .ssume all the reNuired classes are imported. public class Maps 1 public static void main20trin( a89) 1 Map s : ne$ IashMap2)4 s.put2313' 3one3)4 s.put23 3' 3three3)4 s.put2323' 3t$o3)4 0#stem.out.println2s)4 5 5 Options @ .. 11:one' :three'2:t$o5 6. Cannot predict the order C. 1 :three'1:one'2:t$o5 7. 15

22). ;hat $ill be output for the follo$in( pro(ram, public class 6oBin(2 1 public static void main20trin(89 ar(s) 1 b#te b : 1?4 method2b)4 5 static void method2int i)1 0#stem.out.println23)rimitivae T#pe call3)4 5 static void method2&nte(er i)1 0#stem.out.println23;rapper T#pe Call3)4 5 5 a);rapper T#pe Call b))rimitive T#pe Call c)Compiler Drror d)Compiles fine' thro$s runtime eBception

23).

8 of 10

. Thread t = new Thread();

The o!!owin" #ode takes the thread in whi#h state a) $unna%!e %) &ew #) $unnin" d) &one

2'). Tree(et uses )))))))))*ethod o +o*,ara%!e inter a#e to sort the e!e*ents. a) -.ua!s() %) e.au!s/"nore+ase() #) hash+ode() d) #o*,areTo()

25).

0rra12ist3(trin"4 aa = new 0rra12ist3(trin"4(); aa.add(506); aa.add(new (trin"(556)); aa.add(5);

a) +o*,i!es su##ess u!!1. %) Does not #o*,i!e #) (1ntax or 7%8e#t #reation is wron". d) &one

9 of 10

0ubjective. 1) 2) ) %) +) 7escribe the ne$ features of Java -. 2+) DBplain (enerics $ith an eBample 2+) DBplain the difference bet$een Comparable and Comparator $ith an eBample 2+) DBplain &nner class' .non#mous class $ith an eBample 2+) DBplain interthread Communication 2+)

10 of 10

You might also like