GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Quiz

Chapter 3 Core Java APIs

Fausto Trindade 33 Fragen

Quiz starten

Fragen in diesem Quiz (33)

  1. 1What is output by the following code? (Choose all that apply).

    1: public class Fish {
    2: public static void main(String[] args) {
    3: int numFish = 4;
    4: String fishType = "tuna";
    5: String anotherFish = numFish + 1;
    6: System.out.println(anotherFish + " " + fishType);
    7: System.out.println(numFish + " " + 1);
    8: } }
    1. A4 1
    2. B41
    3. C5
    4. D5 tuna
    5. E5tuna
    6. F51tuna
    7. GThe code does not compile.
  2. 2Which of the following are output by this code? (Choose all that apply)
    3: String s = "Hello";
    4: String t = new String(s);
    5: if ("Hello".equals(s)) System.out.println("one");
    6: if (t == s) System.out.println("two");
    7: if (t.equals(s)) System.out.println("three");
    8: if ("Hello" == s) System.out.println("four");
    9: if ("Hello" == t) System.out.println("five");
    1. Aone
    2. Btwo
    3. Cthree
    4. Dfour
    5. Efive
    6. FThe code does not compile.
  3. 3Which are true statements? (Choose all that apply)
    1. AAn immutable object can be modified.
    2. BAn immutable object cannot be modified.
    3. CAn immutable object can be garbage collected.
    4. DAn immutable object cannot be garbage collected.
    5. EString is immutable.
    6. FStringBuffer is immutable.
    7. GStringBuilder is immutable.
  4. 4What is the result of the following code?
    7: StringBuilder sb = new StringBuilder();
    8: sb.append("aaa").insert(1, "bb").insert(4, "ccc");
    9: System.out.println(sb);
    1. Aabbaaccc
    2. Babbaccca
    3. Cbbaaaccc
    4. Dbbaaccca
    5. EAn exception is thrown.
    6. FThe code does not compile.
  5. 5What is the result of the following code?
    2: String s1 = "java";
    3: StringBuilder s2 = new StringBuilder("java");
    4: if (s1 == s2)
    5: System.out.print("1");
    6: if (s1.equals(s2))
    7: System.out.print("2");
    1. A1
    2. B2
    3. C12
    4. DNo output is printed.
    5. EAn exception is thrown.
    6. FThe code does not compile.
  6. 6What is the result of the following code?

    public class Lion {
    public void roar(String roar1, StringBuilder roar2) {
    roar1.concat("!!!");
    roar2.append("!!!");
    }

    public static void main(String[] args) {
    String roar1 = "roar";
    StringBuilder roar2 = new StringBuilder("roar");
    new Lion().roar(roar1, roar2);
    System.out.println(roar1 + " " + roar2);
    } }
    1. Aroar roar
    2. Broar roar!!!
    3. Croar!!! roar
    4. Droar!!! roar!!!
    5. EAn exception is thrown.
    6. FThe code does not compile.
  7. 7Which are the results of the following code? (Choose all that apply)
    String letters = "abcdef";
    System.out.println(letters.length());
    System.out.println(letters.charAt(3));
    System.out.println(letters.charAt(6));
    1. A5
    2. B6
    3. Cc
    4. Dd
    5. EAn exception is thrown.
    6. FThe code does not compile.
  8. 8Which are the results of the following code? (Choose all that apply)

    String numbers = "012345678";
    System.out.println(numbers.substring(1, 3));
    System.out.println(numbers.substring(7, 7));
    System.out.println(numbers.substring(7));
    1. A12
    2. B123
    3. C7
    4. D78
    5. EA blank line.
    6. FAn exception is thrown.
    7. GThe code does not compile.
  9. 9What is the result of the following code?

    3: String s = "purr";
    4: s.toUpperCase();
    5: s.trim();
    6: s.substring(1, 3);
    7: s += " two";
    8: System.out.println(s.length());
    1. A2
    2. B4
    3. C8
    4. D10
    5. EAn exception is thrown.
    6. FThe code does not compile.
  10. 10What is the result of the following code? (Choose all that apply)
    13: String a = "";
    14: a += 2;
    15: a += 'c';
    16: a += false;
    17: if ( a == "2cfalse") System.out.println("==");
    18: if ( a.equals("2cfalse")) System.out.println("equals");
    1. ACompile error on line 14.
    2. BCompile error on line 15.
    3. CCompile error on line 16.
    4. DCompile error on another line.
    5. E==
    6. Fequals
    7. GAn exception is thrown.

Informationen

Beschreibung
OCA JAVA 8 (OCA) Quiz am Chapter 3 Core Java APIs, erstellt von Fausto Trindade am 26/05/2020.
Sprache
Português
Aufrufe
12
Schlagwörter
java 8oca
Bewertung
Noch keine Bewertungen
Bewerte dieses Quiz
Bewerte dieses Quiz

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck