You are on page 1of 20

JAVA

1Who is considered as the creator of JAVA ?


A. Dennis Richie
B. Ken Thompson
C. James Gosling
D. Barne !tro"pstr"p
Correct ans#er is $ C
%&planation
James Gosling is the creator of JAVA. 'e is also called as the Father of Java Programming
Language . (ther persons #ho also contri)"ted to the de*elopment of Ja*a are$ +atric,
-a"ghton. Chris Warth. %d /ran, and 0i,e !heridan
1Which of the follo#ing statements a)o"t the Ja*a lang"age is tr"e?
A.Ja*a s"pports onl2 +roced"ral approach to#ards programming
B.Both +roced"ral and ()ect (riented +rogramming are s"pported in Ja*a
C.Ja*a s"pports onl2 ()ect (riented +rogramming approach
D.-one of the A)o*e
Correct ans#er is $ C
%&planation
Ja*a s"pports onl2 ()ect (riented +rogramming approach as each file has to ha*e atleast 1
((+s element li,e class. interface etc..
3Ja*a is an enhanced *ersion of C44
A. Tr"e
B. /alse
Correct ans#er is $ B
%&planation
Java is NOT an enhanced version of C++ . Ja*a is similar to C44 )"t Ja*a is neither "p#ard
nor do#n#ard compati)le #ith C44.
5
JV0 stands for
XA.Ja*a Verified 0achine
B.Ja*a Virt"al 0achine
C.Ja*a Ver2 large 0achine
D.Ja*a Ver2 small 0achine
Correct ans#er is $ B
%&planation
JV0 stands for for Ja*a Virt"al 0achine and is a ,e2 component if Ja*a #hich helps in cross
platform eporta)ilit2
6JR% stands for
A.Ja*a Real %n*ironment
B.Ja*a Rapid %nterprise
C.Ja*a R"ntime %n*ironment
D.-one of the a)o*e
Correct ans#er is $ C
%&planation
JRE stands for Java Runtime Environment
JRE= JV + Java Pac!age C"asses 7"til.lang ...8 +Runtime Li#raries$9t is essential to r"n a
a*a program on a s2stem.
:
Ja*a so"rce codes are compiled and con*erted to
A. ()ectcodes
B. Assem)l2codes
C. Binar2codes
D. B2tecodes
Correct ans#er is $ D
%&planation
B2tecode is a highl2 optimi;ed set of instr"ctions #hich are "sed in Ja*a to implement
+(RTAB9<9T=. This )2tecode is common for all platforms li,e >ni&. Windo#s. 0ac etc. and is
interpreted )2 the JV0 to r"n the program.

?
What is the %&tension of a*a )2tecodes?
A. .a*a
B. .class
C. .)c
D. -one of the A)o*e
Correct ans#er is $ B
%&planation
The e&tension of a*a )2tecodes is @.class@.
A .a*a file is con*erted into .class file "sing a*ac command.
This .class file is "sed )2 JV0 to r"n the program on different platforms.

A
What is the command to compile a a*a program? 7<et the file name )e m2program.a*a8
A. a*a m2program.a*a
B. a*ac m2program.a*a
C. a*a m2program
D. a*ac m2program
Correct ans#er is $ B
%&planation
The correct #a2 to compile a a*a program is $
a*ac m2program.a*a
Ja*ac means a*aCompiler and generates compiled a*a code called a*a )2tecodes.
B8
What is the command to e&ec"te a a*a program? 7<et the file name )e
m2program.a*a8
A. a*a m2program.a*a
B. a*ac m2program
C. a*a m2program.class
D. a*a m2program
Correct ans#er is $ D
%&planation
The correct command to e&ec"te a a*a program is
a*a m2program
Note% The e&tension $c"ass of the #'tecode is omitted (hi"e e&ecution

1C
Gar)age collection ta,es place a"tomaticall2 in JV0.
A. Tr"e
B. /alse
Correct ans#er is $ A
%&planation
A memor2 )ecomes a*aila)le for Gar)age Collection as soon as last reference to it is lost.
)e can not forcefu""' run *ar#age Co""ector +*C, in Java. Tho"gh 2o" can reD"est for
gar)age collection "sing the -'stem$gc+, command. )"t it does not ensure that the *C (i""
run.
11
JV0 is platform independent
A. Tr"e
B. /alse
Correct ans#er is $ B
%&planation
Do not ma,e this 0ista,e %*erEEEEE
JV is NOT ."atform inde.endent$
The most pop"lar JV0 is called /ot-.ot )2 (racle #hich is #ritten in C44 and th"s. is
+latform Dependent. Different JV0s are needed for different en*ironments li,e Windo#s
specific JV0. >ni& !pecific JV0 etc.

11JAR stands for?
A.Ja*a Archi*e
B.Ja*a Archi*e R"nner
C.Ja*a Application R"nner
D.-one of the a)o*e
Correct ans#er is $ A
%&planation
J0R +Java 0rchive, is an archive fi"e #hich are "sed to gro"p together a*a class files.
metadata. and other reso"rces li,e images #hich are "sed in the application into one compact file
that can )e "sed to distri)"te the application.

13
9s the follo#ing #a2 of commenting correct in Ja*a?
FG02 Comment 1
FG02 Comment 1GF
GF
A. Tr"e
B. /alse
Correct ans#er is $ B
%&planation
-oE -esting of 0"ltiHline comments is not allo#ed in a*a
15
What are the pillars of ((+! concept?
A.A)straction.9nheritance. %ncaps"lation. +ol2morphism
B.Atomicit2. 9nheritance. %ncaps"lation. +ol2morphism
C.A)straction. 9nheritance. +ol2morphism
D.-one of the A)o*e
Correct ans#er is $ A
%&planation
A)straction$ 'iding "nnecessar2 details from the "ser.
9nheritance$ 0aintaining a hierarch2 and re"se of code.
%ncaps"lation$ +rotecting the data of a class . )2 pro*iding access onl2 thro"gh methods.
+ol2morphism$ >sing same name for performing different f"nctions. e&$ /"nction o*erloading.

16
IIIIIIIIIII is a name gi*en to a *aria)le. class or method
A. Constant
B. Reference
C. 9dentifier
D. 0odifier
Correct ans#er is $ C
%&planation
An identifier is a name gi*en to a *aria)le. class or method. 9t "niD"el2 identifies a memor2
space inside a a*a code )loc,.
1:
Ja*a is a strongl2 t2ped lang"age.
A. Tr"e
B. /alse
Correct ans#er is $ A
%&planation
Ja*a is a strongl2 t2ped programming lang"age )eca"se e*er2 *aria)le m"st )e declared #ith a
data t2pe.
1?
Which of the follo#ing can not )e "sed as the first letter to form a *alid a*a identifier?
7Choose all that appl28
A. J
B. K
C. I
D. An2 Alpha)et 7AHL or aH;8
%. An2 -"m)er
Correct ans#er is $ B.%
%&planation
An identifier can onl2 start #ith an "nderscore or an alpha)et.

1A
Ke2#ords and 9dentifiers are same
A. Tr"e
B. /alse
!ee Ans#er K %&planation <ets Disc"ss
Correct ans#er is $ B
%&planation
Ke2#ords are reser*ed #ords #hich constit"tes a programming lang"age li,e if. else. !tring etc..
#hile identifier is the name of a *aria)le . class or o)ect etc . %&$ m2I*ar. i.& etc
1B. What is the *al"e of @d@ after this line of code has )een e&ec"ted?
double d = Math.round ( 2.5 + Math.random() );
A.1
B.3
C.5
D.1.6
Ans#er K %&planation
0ns(er% (ption 1
E&."anation%
The Math.random() method ret"rns a n"m)er greater than or eD"al to 0 and less than 1 .
!ince #e can then )e s"re that the s"m of that n"m)er and 2.5 #ill )e greater than or eD"al to
2.5 and less than 3.5. #e can )e s"re that Math.round() #ill ro"nd that n"m)er to 3. !o
(ption B is the ans#er.
1C. Which of the follo#ing #o"ld compile #itho"t error?
A.int a M 0ath.a)s7H68N
B.int ) M 0ath.a)s76.C8N
C.int c M 0ath.a)s76.6/8N
D.int d M 0ath.a)s76<8N
Ans#er K %&planation
0ns(er% (ption 0
E&."anation%
The ret"rn *al"e of the Math.abs() method is al#a2s the same as the t2pe of the parameter
passed into that method.
9n the case of A. an integer is passed in and so the res"lt is also an integer #hich is fine for
assignment to @int a@.
The *al"es "sed in B. C K D respecti*el2 are a double. a float and a long. The compiler #ill
complain a)o"t a possi)le loss of precision if #e tr2 to assign the res"lts to an @int@.
11. Which of the follo#ing are *alid calls to Math.max?
1. 0ath.ma&71.58
1. 0ath.ma&71.3. 68
3. 0ath.ma&71. 3. 6. ?8
5. 0ath.ma&7H1.6. H1.Af8
A.1. 1 and 5
B.1. 3 and 5
C.1. 1 and 3
D.3 and 5
Ans#er K %&planation
0ns(er% (ption 0
E&."anation%
718. 718. and 758 are correct. The max() method is o*erloaded to ta,e t#o arg"ments of t2pe
int. long. float. or double.
738 is incorrect )eca"se the max() method onl2 ta,es t#o arg"ments.
11.
public class Myfile
{
public static void main (String[] args)
{
String biz = args[1];
String baz = args[];
String rip = args[!];
System"out"println(#$rg is # % rip);
&
&
!elect ho# 2o" #o"ld start the program to ca"se it to print$ Arg is 2
A.a*a 02file 111
B.a*a 02file 1 1 1 3 5
C.a*a 02file 1 3 1 1
D.a*a 02file C 1 1 3
Ans#er K %&planation
0ns(er% (ption C
E&."anation%
Arg"ments start at arra2 element 0 so the fo"rth arg"ement m"st )e 2 to prod"ce the correct
o"tp"t.
13. What #ill )e the o"tp"t of the program?
String ' = ne( String(#'yz#);
String y = #abc#;
' = ' % y;
'o# man2 !tring o)ects ha*e )een created?
A.1
B.3
C.5
D.6
Ans#er K %&planation
0ns(er% (ption C
E&."anation%
<ine 1 creates t#o. one referred to )2 & and the lost !tring @x!@. <ine 1 creates one 7for a
total of three8. <ine 3 creates one more 7for a total of fo"r8. the concatenated !tring referred
to )2 x #ith a *al"e of @x!ab"@.
15. What #ill )e the o"tp"t of the program?
public class )rap*est
{
public static void main(String [] args)
{
int result = +;
s,ort s = -;
.ong ' = ne( .ong(#-#);
.ong y = ne( .ong(-);
S,ort z = ne( S,ort(#-#);
S,ort ' = ne( S,ort(s);
/nteger y = ne( /nteger(#-#);
/nteger z = ne( /nteger(-);
if (' == y) 01 .ine 1! 10
result = 1;
if ('"e2uals(y) ) 01 .ine 13 10
result = result % 1+;
if ('"e2uals(z) ) 01 .ine 14 10
result = result % 1++;
if ('"e2uals(') ) 01 .ine 15 10
result = result % 1+++;
if ('"e2uals(z) ) 01 .ine 1 10
result = result % 1++++;
System"out"println(#result = # % result);
&
&
A.res"lt M 1
B.res"lt M 1C
C.res"lt M 11
D.res"lt M 11C1C
Ans#er K %&planation
0ns(er% (ption 1
E&."anation%
<ine 13 fails )eca"se == compares reference *al"es. not o)ect *al"es. <ine 16 s"cceeds
)eca"se )oth #tring and primiti*e #rapper constr"ctors resol*e to the same *al"e 7e&cept for
the Character #rapper8. <ines 1?. 1B. and 11 fail )eca"se the e$uals() method fails if the
o)ect classes )eing compared are different and not in the same tree hierarch2.
16. What #ill )e the o"tp"t of the program?
public class 6ool*est
{
public static void main(String [] args)
{
int result = +;
6oolean b1 = ne( 6oolean(#*789#);
6oolean b = ne( 6oolean(#true#);
6oolean b! = ne( 6oolean(#t7u9#);
6oolean b- = ne( 6oolean(#false#);
if (b1 == b) 01 .ine 1+ 10
result = 1;
if (b1"e2uals(b) ) 01 .ine 1 10
result = result % 1+;
if (b == b-) 01 .ine 1- 10
result = result % 1++;
if (b"e2uals(b-) ) 01 .ine 1: 10
result = result % 1+++;
if (b"e2uals(b!) ) 01 .ine 1; 10
result = result % 1++++;
System"out"println(#result = # % result);
&
&
A.C
B.1
C.1C
D.1CC1C
Ans#er K %&planation
0ns(er% (ption 2
E&."anation%
<ine 1C fails )eca"se )1 and )1 are t#o different o)ects. <ines 11 and 1A s"cceed )eca"se
the %oolean !tring constr"ctors are case insensiti*e. <ines 15 and 1: fail )eca"se tr"e is not
eD"al to false.
1:. What #ill )e the o"tp"t of the program?
public class <b=>omp
{
public static void main(String [] args )
{
int result = +;
<b=>omp oc = ne( <b=>omp();
<b=ect o = oc;
if (o == oc)
result = 1;
if (o ?= oc)
result = result % 1+;
if (o"e2uals(oc) )
result = result % 1++;
if (oc"e2uals(o) )
result = result % 1+++;
System"out"println(#result = # % result);
&
&
A.1
B.1C
C.1C1
D.11C1
Ans#er K %&planation
0ns(er% (ption 2
E&."anation%
%*en tho"gh o and o" are reference *aria)les of different t2pes. the2 are )oth referring to the
same o)ect. This means that == #ill resol*e to tr"e and that the defa"lt e$uals() method #ill
also resol*e to tr"e.
1?. What #ill )e the o"tp"t of the program?
public class 9'ample
{
public static void main(String [] args)
{
double values[] = {@"!A @1"+A +"3A -&;
int cnt = +;
for (int '=+; ' B values"lengt,; '%%)
{
if (Mat,"round(values['] % "3) == Mat,"ceil(values[']))
{
%%cnt;
&
&
System"out"println(#same results # % cnt % # time(s)#);
&
&
A.same res"lts C time7s8
B.same res"lts 1 time7s8
C.same res"lts 5 time7s8
D.Compilation fails.
Ans#er K %&planation
0ns(er% (ption 1
E&."anation%
Math.round() adds .5 to the arg"ment then performs a floor(). !ince the code adds an
additional .5 )efore round() is called. itOs as if #e are adding 1 then doing a floor(). The
*al"es that start o"t as integer *al"es #ill in effect )e incremented )2 1 on the round() side
)"t not on the "eil() side. and the noninteger *al"es #ill end "p eD"al.
1A. Which statement is tr"e gi*en the follo#ing?
&ouble d = Math.random();
A.C.C P d PM 1.C
B.C.C PM d P 1.C
C.Compilation fail
D.Cannot sa2.
Ans#er K %&planation
0ns(er% (ption 1
E&."anation%
The Math.random() method ret"rns a double *al"e #ith a positi*e sign. greater than or eD"al
to 0.0 and less than 1.0
1B. Which t#o statements are tr"e a)o"t 'ra((er or #tring classes?
1. 9f & and 2 refer to instances of different 'ra((er classes. then the fragment
x.e$uals() #ill ca"se a compiler fail"re.
1. 9f x and refer to instances of different #rapper classes. then x == can sometimes
)e tr"e.
3. 9f x and are #tring references and if x.e$uals() is tr"e. then x == is tr"e.
5. 9f x. . and ! refer to instances of #rapper classes and x.e$uals() is tr"e. and
.e$uals(!) is tr"e. then !.e$uals(x) #ill al#a2s )e tr"e.
6. 9f x and are #tring references and x == is tr"e. then .e$uals(x) #ill )e tr"e.
A.1 and 1
B.1 and 3
C.3 and 5
D.5 and 6
Ans#er K %&planation
0ns(er% (ption 2
E&."anation%
!tatement 758 descri)es an e&ample of the e$uals() method )eha*ing transiti*el2. B2 the #a2.
x. .and ! #ill all )e the same t2pe of 'ra((er. !tatement 768 is tr"e )eca"se x and are
referring to the same #tring o)ect.
!tatement 718 is incorrectQRSthe fragment #ill compile. !tatement 718 is incorrect )eca"se x
== means that the t#o reference *aria)les are referring to the same o)ect. !tatement 738
#ill onl2 )e tr"e if x and refer to the same !tring. 9t is possi)le for x and to refer to t#o
different !tring o)ects #ith the same *al"e.
3C. Which of the follo#ing #ill prod"ce an ans#er that is closest in *al"e to a do")le. d. #hile
not )eing greater than d?
A.7int80ath.min7d8N
B.7int80ath.ma&7d8N
C.7int80ath.a)s7d8N
D.7int80ath.floor7d8N
Ans#er K %&planation
0ns(er% (ption 2
E&."anation%
The casting to an int is a smo,escreen. >se a process of elimination to ans#er this D"estion$
(ption D is the correct ans#er. it is s2ntatheciall2 correct and #ill consistentl2 ret"rn a *al"e
less than d.
(ption A and B are #rong )eca"se )oth the min() and max() methods reD"ire 1 arg"ments
#hereas here the2 are passed onl2 one parameter.
(ption C is #rong )eca"se it co"ld ret"rn a *al"e greater than d 7if d #as negati*e8.
31. What t#o statements are tr"e a)o"t the res"lt o)tained from calling Math.random()?
1. The res"lt is less than C.C.
1. The res"lt is greater than or eD"al to C.C..
3. The res"lt is less than 1.C.
5. The res"lt is greater than 1.C.
6. The res"lt is greater than or eD"al to 1.C.
A.1 and 1
B.1 and 3
C.3 and 5
D.5 and 6
Ans#er K %&planation
0ns(er% (ption 1
E&."anation%
718 and 718 are correct. The res"lt range for random() is 0.0 to P 1.0N 1.0 is not in range.
FOC
1. Which of the follo#ing lang"ages is more s"ited to a str"ct"red program?
A.+<F1
B./(RTRA-
C.BA!9C
D.+A!CA<
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption 2

1. A comp"ter assisted method for the recording and anal2;ing of e&isting or h2pothetical
s2stems is
A.Data transmission
B.Data flo#
C.Data capt"re
D.Data processing
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption 1

3. The )rain of an2 comp"ter s2stem is
A.A<>
B.0emor2
C.C+>
D.Control "nit
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption C

5. What difference does the 6th generation comp"ter ha*e from other generation comp"ters?
A.Technological ad*ancement
B.!cientific code
C.()ect (riented +rogramming
D.All of the a)o*e
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption 0

6. Which of the follo#ing comp"ter lang"age is "sed for artificial intelligence?
A./(RTRA-
B.+R(<(G
C.C
D.C(B(<
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption 1
E&."anation%
+rolog is a general p"rpose logic programming lang"age associated #ith artificial intelligence
and comp"tational ling"istics.
3$ )hich of the fo""o(ing memories is an o.tica" memor'4

A. F"o..' 2is!
B. 1u##"e emories
C$ C25RO
D. Core emories

6$ 2N- refers to

A. 2ata Num#er -e7uence
1$ 2igita" Net(or! -ervice
C. 2omain Name -'stem
D. 2is! Num#ering -'stem


8$
Java (as origina""' invented
#'

A. Orac"e
B. icrosoft
C. Nove""
2$ -un

9$The unit of s.eed used for su.er com.uter is

A. :ELOP-
1$ *ELOP-
C. ELOP-
D. None of these

;<$)hose trademar! is the o.erating s'stem =N>X4

A. otoro"a
B. icrosoft
C$ 1ELL La#oratories
D. 0shtonTate

;;$The first mechanica" com.uter designed #' Char"es 1a##age (as ca""ed

A. 0#acus
1$ 0na"'tica" Engine
C. Ca"cu"ator
D. Processor

;?$)hich of the fo""o(ing is the most .o(erfu" t'.e of com.uter4
A. -u.er5micro
B. -u.er conductor
C$ -u.er com.uter
D. egaframe

;@$)hich gate is a sing"e integrated circuit4

0$ *ate
B. other 1oard
C. Chi.
D. CP=

;A$ C is

0$ 0 third generation high "eve" "anguage
B. 0 machine "anguage
C. 0n assem#"' "anguage
D. 0"" of the a#ove

;B$ )e# .ages are (ritten using

A. FTP
B. /TTP
C$ /TL
D. =RL
;3$ Find the odd man out$

A. Coa&ia" ca#"e
1$ icro(aves
C. O.tica" fi#re
D. T(isted .air (ire

;6$The .arit' #it is added for the .ur.ose of
A. Coding
1$ Error detection
C. Contro""ing
D. >nde&ing


;8$>ndiaCs first su.er com.uter is

A. 0gni
B. F"o( so"ver
C$ Param
D. Trisu"

;9$)hich of the fo""o(ing is NOT o.erating s'stem4

A. 2os
B. =ni&
C. )indo( NT
2$ Java

?<$The com.uter that is not considered as a .orta#"e com.uter is

A. La.to. com.uter
1$ ini com.uter
C. Note#oo! com.uter
D. None of these
11. A techniD"e "sed )2 codes to con*ert an analog signal into a digital )it stream is ,no#n as
A.+"lse code mod"lation
B.+"lse stretcher
C.T"er2 processing
D.T"e"e management
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption 0

11. An optical inp"t de*ice that interprets pencil mar,s on paper media is
A.(.0.R
B.+"nch card reader
C.(ptical scanners
D.0agnetic tape
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption 0

13. 0ost important ad*antage of an 9C is its
A.%as2 replacement in case of circ"it fail"re
B.%&tremel2 high relia)ilit2
C.Red"ced cost
D.<o# po#er cons"mption
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption 1

15. Data di*ision is the third di*ision of a IIIII program.
A.C(B(<
B.BA!9C
C.+A!CA<
D./(RT'
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption 0
E&."anation%
The statements. entries. paragraphs. and sections of a C(B(< so"rce program are gro"ped
into fo"r di*isions.

16. Which lang"age #as de*ised )2 Dr. !e2mo"r Cra2?
A.A+<
B.C(B(<
C.<(G(
D./(RTRA-
%. -one of the a)o*e
Ans#er K %&planation
0ns(er% (ption C

You might also like