1Z0 808-pdf

  • View
    65

  • Download
    12

Embed Size (px)

Text of 1Z0 808-pdf

  • https://www.certification-questions.com/

    1Z0-808PDF

    Oracle 1Z0-808 PDF is available.

    Enrolling now you will get access to 308 unique 1Z0-808 certification questions at: https://www.certification-questions.com/java8-free-pdf-download/1Z0-808-pdf.html

    This is a sample demo for 1Z0-808:

    Q1.Given

    1. classTest{2. 3. publicstaticvoidmain(String[]args){4. 5. int[]a={1,2,3,4,5,6};6. inti=a.length;7. 8. while(i>=1){9. System.out.print(a[i]);10. i--;11. }12. }13. }

    Whatwouldbetheoutput,ifitisexecutedasaprogram?

    A. 123456

    B. 65432

    C. 12345

    D. Anexceptioncouldbethrownatruntime.

    E. Compileerror.

    Discorrect.

    Lengthofarrayais6,sothevalueofthevariableiis6.Executionofwhileloopwilltrytoprintarrayelementreverseasvariableihasinitialvalue6,Sotryingtoaccesselementwithindexposition6willcauseArrayIndexOutOfBoundsExceptionsincethearraypositionsstartwith0.HencethecorrectoptionisD.

  • https://www.certification-questions.com/

    Examobjective: Using Loop Constructs - Create and use while loops

    Creating and Using Arrays - Declare, instantiate, initialize and use a one-dimensional array

    Q2.Given

    1. classEx6{2. publicstaticvoidmain(Stringargs[]){3. inti=0,j=10; 4. try{5. j/=i;6. }7. System.out.print("DividebyZero!");8. catch(Exceptione){9. System.out.print(error);10. }11. } 12. }

    Whatistheoutput?

    A. 0

    B. 0DividebyZero!

    C. DividebyZero!Error

    D. Error

    E. Compilationfails.

    F. Anuncaughtexceptionisthrownatruntime.

    OptionEiscorrect.

    Youcantentercodebetweentryandcatchclause.Hereline7causesthefailure.SotheanswerisE,ifyouremoveline7thencodewillcompilefineandprovideoutputaserrorsointhatcaseanswerwouldbeD.

    Examobjective: Handling Exceptions - Create a try-catch block and determine how exceptions alter normal program flow

  • https://www.certification-questions.com/

    Q3.Consider

    AandEareClasses BandDareinterfaces Cisanabstractclass

    Whicharetrue?(Choose3)

    A. classFimplementsB,C{}

    B. classFimplementsB{}

    C. classFextendsA,E{}

    D. classFextendsE{}

    E. classFimplementsB,D{}

    B,DandEarecorrect.

    Wecanusethekeywordextendstoextendeithertwoclassesortwointerfaces.Inclassitdoesntmatterwhetherabstractornot.Wecanusethekeywordimplementstoimplementaninterfacetoaclass.Multipleinterfacescanbeimplementedbyclassorinterfacebutnotmultipleclasses.SoB,DandEarecorrectaccordingtofollowingreasons.

    Aisincorrectaswetriedtoimplementanabstractclass,buttheabstractclassshouldbeextended.Cisincorrectaswecantextendmorethanoneclassinjava.

    Examobjective: Working with inheritance implement inheritance

  • https://www.certification-questions.com/

    Q4.Given

    1. classTest{

    2. publicstaticvoidmain(String[]args){

    3. inta[]={};

    4. System.out.print(ainstanceofObject);

    5. }

    6. }

    Note:Thekeywordinstanceofisusetocheckwhetheranobjectisofaparticulartype

    Whichistrue?

    A. Willproduceoutputasfalse.

    B. Compilationfailsduetoerroratline3.

    C. Willproduceoutputastrue.

    D. Compilationfailsduetoerroratline4.

    E. Lengthofthisarrayis3.

    Ciscorrect.

    CodewillcompilefinesoCiscorrect.ItproducetrueastheoutputasarrayistypeofobjectsoitreturnstruesotheanswerCiscorrectandAisincorrect.

    Examobjective: Creating and Using Arrays - Declare instantiate, initialize and use a one-dimensional array.

  • https://www.certification-questions.com/

    Q5.Given

    1. classProgram{

    2. staticIntegeri;

    3. publicstaticvoidmain(String[]args){

    4. try{

    5. System.out.println(i.compareTo(0));

    6. }catch(ArithmeticException|NullPointerExceptione){

    7. System.out.println("Exception");

    8. }

    9. }

    10. }

    Whichistheoutput?

    A. -1

    B. 0

    C. 1

    D. Exception

    E. Compilationfails.

    OptionDiscorrect.

    Fromjavase8,wecanusecatchboxformultiexceptionssothiscodecompilesfine.IngivencatchboxitcancatchbothArithmeticExceptionandNullPointerException.Atline7,aNullPointerExceptionwillbethrownsinceIisnotinitialized.HenceoptionDiscorrect.

    Examobjective:HandlingExceptions-Createatry-catchblockanddeterminehowexceptionsalternormalprogramflow

  • https://www.certification-questions.com/

    Q6.Given

    1. classEx1{

    2. publicstaticvoidmain(String[]args){

    3. inta[]={1,2,053,4};

    4. intb[][]={{1,2,4},{2,2,1},{0,43,2}};

    5. System.out.print(a[3]==b[0][2]);

    6. System.out.print(""+(a[2]==b[2][1]));

    7. }

    8. }

    Whichistheoutput?

    A. truefalse

    B. falsefalse

    C. falsetrue

    D. truetrue

    E. Compilationfails

    Discorrect.

    Indexingofarrayelementsbeginwithzero.So[1]referstothesecondelementofanarray.Soherea[3]referstothefourthelementofarraya.Itsvalueis4andwehaveassigned4tob[0][2].Wehaveassignedoctalvaluetoa[2]sothevalueofelementis43indecimals.Andwehaveassigned43indecimaltob[2][1].Sobothwillprinttrue

    AccordingtoabovereasonsA,BandCareincorrect.Eisincorrectascodecompilesfine.

    Examobjective: Creating and Using Arrays - Declare instantiate, initialize and use a one-dimensional array.

    Declare, instantiate, initialize and use multi-dimensional array

  • https://www.certification-questions.com/

    Q7.Choosethreelegalidentifiers.

    A. 2ndtName

    B. _8_

    C. &name

    D. $

    E. new

    BandDarecorrect.

    Identifierscanstartwithaletter,adollarmarkoranunderscore.Theycanhaveanylength.Itisgoodpracticetodefineidentifiersmeaningfullynotlikehereasitwillmakeeasytoreadyoucodewhenreviewneeded.Alsowecantuseanyreservedkeywordforvariablename.HenceEisincorrectasnewisreservedkeyword.

    Aisincorrectasitstartswithanumber.

    Cisincorrectasitstartwith&.

    Examobjective: Working With Java Data Types - Declare and initialize variables

  • https://www.certification-questions.com/

    Q8.Given

    1. classTest{

    2. intvalue=10;

    3. publicstaticvoidmain(String[]args){

    4. newTest().print();

    5. }

    6. publicvoidprint(){

    7. intvalue=8;

    8. System.out.print(value);

    9. }

    10. }

    Whichistheoutput?

    A. 8

    B. 10.

    C. Compilationfailsduetoerroratline4.

    D. Compilationfailsduetoerroratline7.

    Aiscorrect.

    Insideaclassmethod,whenalocalvariablehavethesamenameasoneoftheinstancevariable,thelocalvariableshadowstheinstancevariableinsidethemethodblock.Sothevalueofa(8)inmethodprint()canseeastheoutput.SotheanswerisA.

    Bisincorrectastheinstancevariableisshadowedbythevariableinthemethodprint().

    Thecodecompilesfine,henceCandDareincorrect.

    Examobjective: Java Basics - Define the scope of variables

  • https://www.certification-questions.com/

    Q9.Given

    1. classTest{

    2. staticintx=0;

    3. publicstaticvoidmain(String[]args){

    4. for(intx=0;x

  • https://www.certification-questions.com/

    Q10.Given

    1. classExer{

    2. publicstaticvoidmain(String[]args){

    3. Strings="Java";

    4. s.concat("SE7");

    5. s.replaceAll(7,);

    6. System.out.print(s);

    7. }

    8. }

    Whatistheresult?

    A. JavaSE

    B. JavaSE7

    C. JavaSE

    D. Java.

    E. Compilationfails.

    Discorrect.

    LinethreecreateanewStringobjectandgivesitthevalueJava.LinefourandfivemodifiedtheStringjavabutthereisnoreferenceusedtoreferthatmodifiedobjects.SoitreallycreatestwouselessStringobjects.SoattheendsstaysasJava.

    SotheA,BandCareincorrectastheStringsremainsunchangedasexplainedabove.

    Examobjective: Working With Java Data Types - Create and manipulate strings

  • https://www.certification-questions.com/

    Q11.Whicharetrue?

    A. Defaultconstructorshouldbealwaysthereforanyclass.

    B. Defaultconstructoronlycontainsthis();.

    C. Whendefiningourownconstructorwecantuseanyaccessmodifier.

    D. Aconstructorshouldnothaveareturntype.

    E. Wecantchangedefaultconstructorofaninterface.

    Discorrect.

    WecanuseanyaccessmodifierConstructor,soCisincorrect.Eisincorrectasinterfacesdonothaveconstructors.

    Aisincorrectaswhenthereisuserdefinedconstructor,thedefaultconstructorvanishsoitisnotamust,howeveratleastoneconstructorshouldpresent.

    Bisincorrectasdefaultconstructorhassuper();.

    Examobjective: Working with Methods and Encapsulation - Differentiate between default and user-defined constructors

  • https://www.certification-questions.com/

    Q12.Considerfollowingthreestatements

    I.Overloadedmethodmustchangetheargumentlist.

    II.Overloadedmethodmaychangethereturntype.

    III.Overloadedmethodmaydeclarebroadercheckedexception.

    Whichistrue?

    A. Ionly

    B. IIonly

    C. IIIonly

    D. IandIIonly

    E. all

    Eiscorrect

    AnswerisEcorrectasallgivenstatementsarecorrect.

    StatementIiscorrectasoverloadedmethodmustchangetheargumentlist.

    StatementIIiscorrectasoverloadedmethodsmaychangethereturntype.

    StatementIIIiscorrectastheycanthrowneworbroaderexceptions.

    Examobjective:WorkingwithMethodsandEncapsulationCreate an overloaded method

  • https://www.certification-questions.com/

    Q13.Given

    1. classSup{2. protectedvoidmethod(intx){3. System.out.print("Sup"+x);4. }5. }6. classSubextendsSup{7. //overloadmethod()here8. }

    Consider

    I. publicvoidmethod(){}

    II. privatefinalintmethod(inti){returni;}

    III. privatefinalvoidmethod(Strings)throwsException{}

    Whichistrue?

    A. Ionly

    B. IIonly

    C. IandIIIonly

    D. IandIIonly

    E. all

    Ciscorrect.

    IIisincorrectsincetherewehaventchangetheargumentlis