¡GoConqr estrena diseño! Cuéntanos qué te parece.

Test

Java Building blocks

Joshua Salcedo 23 preguntas

Hacer el test

Preguntas del test (23)

  1. 1Which of the following are valid Java identifiers?(Choose all that apply)
    1. AA$B
    2. B_helloWorld
    3. Ctrue
    4. Djava.lang
    5. EPublic
    6. F1980_s
  2. 2What is the output of the following program?
    1: public class WaterBottle{
    2: private String brand;
    3: private boolean empty;
    4: public static void main(String [] args){
    5: WaterBottle wb = new WaterBottle();
    6: System.out.print("Empty = " + wb.empty);
    7: System.out.print(", Brand = " + wb.brand);
    8: } }
    1. ALine 6 generates a compiler error
    2. BLine 7 generates a compiler error.
    3. CThere is no output
    4. DEmpty = false, Brand = null
    5. EEmpty = false, Brand =
    6. FEmpty = null, Brand = null
  3. 3Which of the following are true?(Choose all that apply)
    4: short numPets = 5;
    5: int numGrains = 5.6;
    6: String name = "Scruffy";
    7: numPets.length();
    8: numGrains.length();
    9: name.length();
    1. ALine 4 generates a compiler error
    2. BLine 5 generates a compiler error
    3. CLine 6 generates a compiler error
    4. DLine 7 generates a compiler error
    5. ELine 8 generates a compiler error
  4. 4Given the following class, which of the following is true? (Choose all that apply)
    1: public class Snake{
    2:
    3: public void shed(boolean time){
    4:
    5: if(time){
    6:
    7: }
    8: System.out.println(result);
    9:
    10: }
    11: }
    }
    }
    1. AIf String result = "done"; is inserted on line 2, the code will compile.
    2. BIf String result = "done"; is inserted on line 4 the code will compile.
    3. CIf String result = "done"; is inserted on line 6, the code will compile.
    4. DIf String result = "done"; is inserted on line 9, the code will compile.
    5. ENone of the above changes will make the code compile
  5. 5Given the following classes which of the following can independently replace INSERT IMPORTS HERE to make the code compile? (choose all that apply)

    package aquarium;
    public class Tank{}

    package aquarium.jellies;
    public class Jelly{ }

    package visitor;
    INSERT IMPORTS HERE
    public class AquariumVisitor{
    public void admire(Jelly jelly){}}
    1. Aimport aquarium.*;
    2. Bimport aquarium.*.Jelly;
    3. Cimport aquarium.jellies.Jelly;
    4. Dimport aquarium.jellies.*;
    5. Eimport aquarium.jellies.Jelly.*;
    6. FNone of these can make the code compile
  6. 6Given the following classes, what is the maximum number of imports that can be removed and have the code still compile?

    package aquarium; public class Water{ }

    package aquarium;
    import java.lang.*;
    import java.lang.System;
    import aquarium.Water;
    import aquarium.*;
    public class Tank{
    public void print(Water water){
    System.out.println(water);}}
    1. A0
    2. B1
    3. C2
    4. D3
    5. E4
    6. FDoes not compile
  7. 7Given the following classes, which of the following snippets can be inserted in place of INSERT IMPORTS HERE and have the code compile? (choose all that apply)

    package aquarium;
    public class Water{
    boolean salty = false;
    }
    package aquarium.jellies;
    public class Water{
    boolean salty = true;
    }
    package employee;
    INSERT IMPORTS HERE
    public class WaterFiller{
    Water water;
    }
    1. Aimport aquarium.*;
    2. Bimport aquarium.Water;
      import aquarium.jellies.*;
    3. Cimport aquarium.*;
      import aquarium.jellies.Water;
    4. Dimport aquarium.*;
      import aquarium.jellies.*;
    5. Eimport aquarium.Water;
      import aquarium.jellies.Water;
    6. FNone of these imports can make the code compile
  8. 8Given the following class, which of the following calls print out Blue Jay?(choose all that apply)
    public class BirdDisplay{
    public static void main(String[] name){
    System.out.println(name[1]);
    }}
    1. Ajava BirdDisplay Sparrow Blue Jay
    2. Bjava BirdDisplay Sparrow "Blue Jay"
    3. Cjava BirdDisplay Blue Jay Sparrow
    4. Djava BirdDisplay "Blue Jay" Sparrow
    5. Ejava BirdDisplay.class Sparrow "Blue Jay"
    6. Fjava BirdDisplay.class "Blue Jay" Sparrow
    7. GDoes not compile
  9. 9Which of the following legally fill in the blank so you can run the main() method from the command line?(Choose all that apply)
    public static void main(___________)
    1. AString[] _names
    2. BString [] 123
    3. CString abc[]
    4. DString _Names[]
    5. EString ... $n
    6. FString names
    7. GNone of the above
  10. 10Which of the following are legal entry point methods that can be run from the command line? (Chose all that apply)
    1. Aprivate static void main(String[] args)
    2. Bpublic static final main(String[] args)
    3. Cpublic void main(String[] args)
    4. Dpublic static void test(String[] args)
    5. Epublic static void main(String[] args)
    6. Fpublic static main(String[] args)
    7. GNone of the above

Información

Descripción
Oracle Certified Associate
Idioma
English
Visitas
21
Valoración
Aún sin valoraciones
Valora este test
Valora este test

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?