You are on page 1of 28

SL275

QUESTION 1.
QUESTION 2.
Given the exhibit.
Given the code in the exhibit.
What is the result?
A. Compilation fails
B. An exception is thrown at runtime.
C. An instance of Forest is serialized.
D. An instance of Forest and an instance of ree are both serialized.
What is the result?
A. ! B. " C. #
D. Compilation fails $. An exception is thrown at runtime
QUESTION 3.
When comparin% &ava. 'o. BufferedWriter to &ava.io.FileWriter( which capabilit)
exist as a method in onl) one of the two?
A. closin% the stream
B. flushin% the stream
C. writin% to the stream
D. mar*in% a location in the stream
$. writin% a line separator to the stream
QUESTION 4.
Which three statements concernin% the use of the &ava . io. +ealizable interface are
true? ,choose three-
A. .b&ect from classes that use a%%re%ation cannot be serialized.
B. An ob&ect serialized on one /01 can be successfull) desterilized on a different /01.
C. he values in fields with the 0olatile modifier will 2. survive serialization and
deserialization
D. he values in field with the transient modifier will 2. survive serialization and
deserialization
$. 't is le%al to serialize an ob&ect of a t)pe that has a supert)pe that does 2. implement
&ava .io.3erialization
QUESTION 5.
Which two statements are true? ,Choose two-
A.An encapsulated(public class promoters re4use.
B.Classes that share the same interface are alwa)s ti%htl) encapsulated
C.An encapsulated class allows subclasses to overload methods(but does 2. allow
overridin% methods
D.An encapsulated class allows a pro%rammer to chan%e an implementation without
affectin% outside code
QUESTION 6.
$xhibit5
Which two are possible results? ,choose two-
A. !(6(#(#(7(8("!(7(
B. !(6(#(7(8("!(6(#(
C. !(6(#(7(8("!("6("#(
D. !(!(6(6(#(#(7(7(8(8("!("!("6("6("#("#(
$. !(6(#(7(8("!("6("#(!(6(#(7(8("!("6("#(
QUESTION 7.
Given the exhibit5
What can be a result?
A. Compilation fails
B. An exception is thrown at runtime
C. he code executes and prints 93tartedComplete9
D. he code executes and prints 93tartedComplete!"6:9
$. he code executes and prints 93tarted!"6:Complete9
QUESTION 8.
Which three will compile and run without exception? ,choose three-
A. private s)nchronized ob&ect o;
B. void %o , - <
s)nchronized , - < => ocde here >= ?
?
C. public s)nchronized void %o , - < => code here >= ?
D. private s)nchronized ,this- void %o , - < => code here >= ?
$. void %o , - <
s)nchronized ,ob&ect.class- < => code here >= ?
?
F. void %o , - <
s)nchronized ,o- < => code here >= ?
?
QUESTION 9.
Given the exhibit5
What is the result?
A. Compilation fails
B. An exception is thrown at runtime
C. he code executes normall) and prints 9sleep9
D. he code executes normall)( but nothin% is printed.
QUESTION 10.
Given the exhibit5
What can directl) access and chan%e the value of the variable name?
A. an) class
B. onl) the ar%et class
C. an) class in the Cert*iller pac*a%e
D. an) class that extends ar%et
QUESTION 11.
$xhibit5
What is the result?
A. 0alue is 5 8
B. Compilation fails.
C. 0alue is 5 "6
D. 0alue is ; 4"6
$. he code runs with no output
F. An exception is thrown at runtime.
QUESTION 12.
Given the exhibit5
What is the result?
A. peep
B. bar*
C. meow
D. Compilation fails.
$. An exception is thrown at runtime
QUESTION 13.
Given the exhibit5
What three code fra%ments inserted individuall) at line "@( ma*e use of
pol)morphism? ,choose three-
A. public void add ,C c- < c.%et0alue , -; ?
B. public void add ,B b- < b.%et0alue , -; ?
C. public void add ,A a- < a.%et0alue , -; ?
D. public void add ,A a( B b- < a.%et0alue , -; ?
$. public void add ,C c" C c6- < c".%et0alue , -; ?
QUESTION 14.
Exhibit:

What is the output of the pro%ram shown in the exhibit?
A. :!!."!!."!!."!!."!!
B. :!!.:!!."!!."!!."!!
C. :!!.:!!.:!!."!!."!!
D. :!!.:!!.:!!.:!!."!!
QUESTION 15.
Given the exhibit5
Which statement is true about the ob&ect referenced b) snoo%( smooch and booch
immediatel) after line 6: executes?
A. 2one of these ob&ects are eli%ible for %arba%e collection
B. .nl) the ob&ect referenced b) booch is eli%ible for %arba%e collection
C. .nl) the pb&ect referenced b) snoo% is eli%ible for %arba%e colletion
D. .nl) the ob&ect referenced b) smooch is eli%ible for %arba%e collection
$. he ob&ects referenced b) smooch and booch are eli%ible for %arba%e collection
QUESTION 16.
Given the exhibit:
What is the result?
A. r( t( t
B. r( e( o(
C. Compilation fails
D. An exception is thrown at runtime
QUESTION 17.
Given classes defined in two different files5
What is reAuired at line @ in class Cert*iller App to use the process method of Bit Btils?
A. Crocess ,b)tes-;
B. BitBtils.process ,b)tes-;
C. Btil.BitBtils.process ,b)tes-;
D. Cert*iller App cannot use methods in BitBtils
$. 'mport util.BitBtils.>; process ,b)tes-;
QUESTION 18.
Given classes defined in two different files
What is reAuired at line @ in class Cert*iller Application to use the process method of
BitBtils?
A. C+.C$33 ,BD$3-;
B. BitBtils.process,b)tes-;
C. App.BitBtils.process ,b)tes-
D. Btil.BitBtils. process ,b)tes-
$. 'mport util.BitBtils.>; process ,b)tes-;
F. Cert*iller Application cannot use the process method in BitBtils.
QUESTION 19.
Given the exhibit5
Which code( inserted at line "#( allows the 3prite class to compile?
A. Direction d E 2.+F
B. Cert*iller .Direction d E 2.+F
C. Direction d E Direction.2.+F
D. Cert*iller .Direction d E Cert*iller Direction. 2.+F
QUESTION 20.
Given the exhibit5
What is the output from line @ of the Cert*iller class?
A. @
B. "!
C. "6
D. "G
$. 6#
QUESTION 21.
$xhibit5
What is the result?
A. snootch) #6! third second first
B. snootch) #6! first second third
C. first second third snootch) #6!
D. third second first snootch) #6!
$. thirds first second snootch) #6!
F. first second first third snootch) #6!
QUESTION 22.
A /ava Bean component has the followin% field5
"". C+'0A$ B..H$A2 $2ABH$D5
Which two pairs of method declarations follow the /avaBean standard for accessin%
this fields? ,choose two-
A. public void set$nabled , Boolean enabled-
public Boolean %et$nabled , -
B. public void set$nabled , Boolean enabled-
public void is$nabled , -
C. public void set$nabled , Boolean enabled-
public Boolean is$nabled , -
D. public void set$nabled , Boolean enabled-
public Boolean %et$nabled , -
QUESTION 23.
Given the exhibit5
Which two classes use the 3hape class correctl)? , choose two-
A. public class Circle implements 3hape <
private int radius;
?
B. public abstract class Circle extends 3hape <
private int radius;
?
C. public class Circle extend 3hape <
private int radius;
public void draw , -;
?
D. public abstract class Circle implements 3hape <
private int radius;
public void draw , -;
?
$. public class Circle extends 3hape <
private int radius;
public void draw ,- < =>C.D$ F$+$ >=?
?
F. public AB3+AC class Circle implements 3hape <
private int radius;
public void draw , - < => code here >= ?
?
QUESTION 24.
Given the exhibit5
What is the result if 2ullCointer$xception occurs on line :#?
A. c
B. a
C. ab
D. ac
$. bc
F. abc
QUESTION 25.
$xhibit5
Which two statements are truee if a 2ullCointer$xception is thrown on line : of
class C? ,choose two-
A. he application will crash.
B. he code on line 6I will be executed
C. he code on line @ of class A will execute.
D. he code on line @ of class B will execute.
$. he exception will be propa%ated bac* to line 6G.
QUESTION 26.
Given the exhibit5
What is the result?
A. he value 9#9 is printed at the command line
B. Compilation fails because of an error in line @.
C. Compilation fails because of an error in line I.
D. A 2ullC.'2$+eJC$C'.2 .CCB+3 A +B2'1$.
$. A 2umberFormat$xception occurs at runtime.
F. An 'lle%al3tate$xception occurs at runtime.
QUESTION 27.
Given the exhibit5
What is the result when method test'fA is invo*ed?
A. rue
B. 2ot true
C. An exception is thrown at runtime
D. Compilation fails because of an error at line "6.
$. Compilation fails because of an error at line "I.
QUESTION 28.
G'0$2 F$ $JF'B'5
What is the result?
A. null
B. zero
C. some
D. Compilation fails
$. An exception is thrown at runtime
QUESTION 29.
Given the exhibit5
What is the result?
A. Compilation fails
B. aAaA aAa AAaa AaA
C. AAaa AaA aAa aAaA
D. AaA AAaa aAaA aAa
$. aAa AaA aAaA AAaa
F. An exception is thrown at runtime
QUESTION 30.
Given a pre4%enerics implementation of a method5
Which three chan%es must be made to the method sum to use %enerics? ,choose
three-
A. remove line "#
B. replace line "# with 9int ' E iter.next , -; 9
C. replace line ": with 9for , int ' 5 intHist - <9
D. replace line ": with 9 for ,'terator iter 5 intHiswt - 9
$. replace the method declaration with 9sum ,HistKintL intHist-9
F. replace the method declaration with 9sum , HistK'nte%erL intHist-9
QUESTION 31.
Given the exhibit5
What is the result?
A. apple5apple
B. carrot5apple
C. apple5banana
D. banana5apple
$. carrot5carrot
F. carrot5banana
QUESTION 32.
Given the exhibit5
Which two( inserted at line "" will allow the code to compile? ,Choose wo-
A. public class 1in1axK ? L <
B. public class 1in1ax K ? extends 2umberL <
C. public class 1in1ax K2 extends .b&ectL <
D. public class 1in1ax K2 extends 2umber L <
$. public class 1in1ax K ? extends .b&ect L <
F. public class 1in1ax K 2 extends 'nte%er L <
QUESTION 33.
Given5
Which line of code mar*s the earliest point that an ob&ect referenced b) int.b&
becomes a candidate for %arba%e collection?
A. Hine "7
B. Hine "G
C. Hine "8
D. Hine "I
$. he ob&ect is 2. a candidate for %arba%e collection.
QUESTION 34.
A class %ames.cards.Co*er is correctl) defined in the &ar file Co*er.&ar. A user wants
to execute the main method of Co*er on a B2'J s)stem usin% the command5
/ava %ames.cards.Co*er
What allows the user to do this?
A. put Co*er.&ar in director) =stuff=&ava( and set the CHA33CAF to include =stuff=&ava
B. put Co*er.&ar in director) =stuff=&ava( and set the CHA33CAF to include
=stuff=&ava=>.&ar
C. put Co*er.&ar in director) =stuff=&ava( and set the CHA33CAF to include
=stuff=&ava=Co*er.&ar
D. put Co*er.&ar in director) =stuff=&ava=%ames=cards( and set the CHA33CAF to include
=stuff=&ava
$. put Co*er.&ar in director) =stuff=&ava=%ames=cards( and set the CHA33CAF to include
=stuff=&ava=>.&ar
F. put Co*er.&ar in director) =stuff=&ava=%ames=cards( and set the CHA33CAF to include
=stuff=&ava=Co*er.&ar
QUESTION 35.
Given a class +epetition5
And %iven another class Demo5
Which code should be inserted at line " of Demo.&ava to compile and run Demo to
print 9pizzapizza9
A. import utils.>;
B. static import utils.>;
C. import utils.+epetition.>;
D. static import utils.+epetition.>;
$. import utils.+epetition.twice,-;
F. import static utils.+epetition.twice;
G. static import utils.+epetition.twice;

QUESTION 36.
$xhibit5
Given the full)4Aualified class names5
com.foo.bar.Do%
com.foo.bar.blatz.Boo*
com.bar.Car
com.bar.blatz.3un
Which %raph represents the correct director) structure for a /A+ file from which
those classes can be used b) the compiler and /01?
A. /ar A
B. /ar B
C. /ar C
D. /ar D
$. /ar $
QUESTION 37.
Given5
What is the result?
A. Compilation fails
B. An exception is thrown at runtime
C. do3tuff x E 7 main x E 7
D. do3tuff x E @ main x E @
$. do3tuff x E @ main x E 7
F. do3tuff x E 7 main x E @
QUESTION 38.
Given5
What is the result?
A. $xception
B. A( B( $xception
C. Compilation fails because of an error in line 6!.
D. Compilation fails because of an error in line "#.
$. A 2ullCointer$xception is thrown at runtime.
QUESTION 39.
Given5
What is the result?
A. A( B( C
B. B( C( A
C. Compilation fails
D. he code runs with no output
$. An exception is thrown at runtime
QUESTION 40.
Given5
A. he instance %ets %arba%e collected.
B. he code on line :: throws an exception.
C. he code on line :@ throws an exception.
D. he code on line :" throws an exception.
$. he code on line :: executes successfull).
QUESTION 41.
Given5
Which code( inserted at line "7 will cause a &ava.lan%.ClassCast$xception?
A. Alpha a E x;
B. Foo f E ,Delta-x;
C. Foo f E ,Alpha-x;
D. Beta b E ,Beta-,Alpha-x;
QUESTION 42.
Given5
Which two will produce an Assertion$rror? ,Choose two.-
A. &ava test
B. &ava 4ea test
C. &ava test file"
D. &ava 4ea test file"
$. &ava 4ea test file" file6
F. &ava 4ea5test test file"
QUESTION 43.
Assumin% that the serializeBanana,- and the deserializeBanana,- methods will correctl)
use /ava serialization and %iven5
What is the result?
A. restore #!!
B. restore #!:
C. restore #@:
D. Compilation fails.
$. An exception is thrown at runtime.
QUESTION 44.
Given5
What is the result?
A. int Hon%
B. 3hort Hon%
C. Compilation fails
D. An exception is thrown at runtime.
QUESTION 45.
Given5
What creates the appropriate DateFormat ob&ect and adds a da) to the Date ob&ect?
A. :@. Dateformat df E DateFormat.%etDateFormat,-;
#6. d.setime , ,7! > 7! > 6#- M d.%etime,--;
B. :@. Dateformat df E DateFormat.%etDate'nstance,-;
#6. d.setime , ,"!!! > 7! > 7! > 6#- M d.%etime,--;
C. :@. Dateformat df E DateFormat.%etDateFormat,-;
#6. d.setHocalime , ,"!!! > 7! > 7! > 6#- M d.%etHocalime,--;
D. :@. Dateformat df E DateFormat.%etDate'nstance,-;
#6. d.setHocalime , ,7! > 7! > 6#- M d.%etHocalime,--;
QUESTION 46.
Given5
Which three will compile successfull)? ,Choose three.-
A. .b&ect o E .ld.%et!,new Hin*edHist,--;
B. .b&ect o E .ld.%et!,new Hin*edHistK?L,--;
C. 3trin% s E .ld.%et!,new Hin*edHistK3trin%L,--;
D. .b&ect o E .ld.%et!,new Hin*edHistK.b&ectL,--;
$. 3trin% s E ,3trin%-.ld.%et!,new Hin*edHistK3trin%L,--;

QUESTION 47.
Given5
What is the appropriated definition of the hashCode method in class Cerson?
A. return super.hashCode,-;
B. return name.hashCode,- M a%e > G;
C. return name.hashCode,- M comment.hashCode,- = 6;
D. return name.hashCode,- M comment.hashCode,- = 6 4 a%e > :;

QUESTION 48.
Given5
Which code( inserted at line #( %uarantees that this pro%ram will output N"( 6O?
A. 3et set E new ree3et,-;
B. 3et set E new Fash3et,-;
C. 3et set E new 3orted3et,-;
D. Hist set E new 3ortedHist,-;
$. 3et set E new Hin*edFash3et,-;
QUESTION 49.
Which two code fra%ments will execute the method do3tuff,- in a separate thread?
,Choose two.-
A. new hread,- <
public void run,- < do3tuff,- ;?
?;
B. new hread,- <
public void start,- < do3tuff,-; ?
?;
C. new hread,- <
public void start,- < do3tuff,-; ?
?.run,-;
D. new hread,- <
public void run,- < do3tuff,-; ?
?.start,-;
$. new hread,new runnable,- <
public void run,- < do3tuff,-; ?
?-.run,-;
F. new hread,new runnable,- <
public void run,- < do3tuff,-; ?
?-.start,-;
QUESTION 50.
Given5
Which three chan%es should be made to adapt this class to be used safel) b)
multiple threads? ,Choose three.-
A. declare reset,- usin% the s)nchronized *e)word
B. declare %et2ame,- usin% the s)nchronized *e)word
C. declare %etCount,- usin% the s)nchronized *e)word
D. declare the constructor usin% the s)nchronized *e)word
$. declare increment,- usin% the s)nchronized *e)word

You might also like