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

Quiz

Assessment Test

JESSY ANDRES GOMEZ SARMIENTO 30 Fragen Aktualisiert am 23 Sep 2022

Quiz starten

Fragen in diesem Quiz (30)

  1. 11. What is the result of executing the following code snippet?

    41: final int score1 = 8, score2 = 3;
    42: char myScore = 7;
    43: var goal = switch (myScore) {
    44: default -> {if(10>score1) yield "unknown";}
    45: case score1 -> "great";
    46: case 2, 4, 6 -> "good";
    47: case score2, 0 -> {"bad";}
    48: };
    49: System.out.println(goal);
    1. AA. unknown
    2. BB. great
    3. CC. good
    4. DD. bad
    5. EE. unknowngreatgoodbad
    6. FF. Exactly one line needs to be changed for the code to compile.
    7. GG. Exactly two lines need to be changed for the code to compile.
    8. HH. None of the above
  2. 22. What is the output of the following code snippet?

    int moon = 9, star = 2 + 2 * 3;
    float sun = star>10 ? 1 : 3;
    double jupiter = (sun + moon) - 1.0f;
    int mars = --moon <= 8 ? 2 : 3;
    System.out.println(sun+", "+jupiter+", "+mars);
    1. AA. 1, 11, 2
    2. BB. 3.0, 11.0, 2
    3. CC. 1.0, 11.0, 3
    4. DD. 3.0, 13.0, 3
    5. EE. 3.0f, 12, 2
    6. FF. The code does not compile because one of the assignments requires an explicit
      numeric cast.
  3. 33. Which changes, when made independently, guarantee the following code snippet
    prints 100 at runtime? (Choose all that apply.)

    List<Integer> data = new ArrayList<>();
    IntStream.range(0,100).parallel().forEach(s -> data.add(s));
    System.out.println(data.size());
    1. AA. Change data to an instance variable and mark it volatile.
    2. BB. Remove parallel() in the stream operation.
    3. CC. Change forEach() to forEachOrdered() in the stream operation.
    4. DD. Change parallel() to serial() in the stream operation.
    5. EE. Wrap the lambda body with a synchronized block.
    6. FF. The code snippet will always print 100 as is.
  4. 44. What is the output of this code?

    20: Predicate<String> empty = String::isEmpty;
    21: Predicate<String> notEmpty = empty.negate();
    22:
    23: var result = Stream.generate(() -> "")
    24: .filter(notEmpty)
    25: .collect(Collectors.groupingBy(k -> k))
    26: .entrySet()
    27: .stream()
    28: .map(Entry::getValue)
    29: .flatMap(Collection::stream)
    30: .collect(Collectors.partitioningBy(notEmpty));
    31: System.out.println(result);
    1. AA. It outputs {}.
    2. BB. It outputs {false=[], true=[]}.
    3. CC. The code does not compile.
    4. DD. The code does not terminate.
  5. 55. What is the result of the following program?

    1: public class MathFunctions {
    2: public static void addToInt(int x, int amountToAdd) {
    3: x = x + amountToAdd;
    4: }
    5: public static void main(String[] args) {
    6: var a = 15;
    7: var b = 10;
    8: MathFunctions.addToInt(a, b);
    9: System.out.println(a); } }
    1. AA. 10
    2. BB. 15
    3. CC. 25
    4. DD. Compiler error on line 3
    5. EE. Compiler error on line 8
    6. FF. None of the above
  6. 66. Suppose that we have the following property files and code. What values are printed
    on lines 8 and 9, respectively?

    Penguin.properties
    name=Billy
    age=1

    Penguin_de.properties
    name=Chilly
    age=4

    Penguin_en.properties
    name=Willy

    5: Locale fr = new Locale("fr");
    6: Locale.setDefault(new Locale("en", "US"));
    7: var b = ResourceBundle.getBundle("Penguin", fr);
    8: System.out.println(b.getString("name"));
    9: System.out.println(b.getString("age"));
    1. AA. Billy and 1
    2. BB. Billy and null
    3. CC. Willy and 1
    4. DD. Willy and null
    5. EE. Chilly and null
    6. FF. The code does not compile.
  7. 77. What is guaranteed to be printed by the following code? (Choose all that apply.)

    int[] array = {6,9,8};
    System.out.println("B" + Arrays.binarySearch(array,9));
    System.out.println("C" + Arrays.compare(array,
    new int[] {6, 9, 8}));
    System.out.println("M" + Arrays.mismatch(array,
    new int[] {6, 9, 8}));
    1. AA. B1
    2. BB. B2
    3. CC. C-1
    4. DD. C0
    5. EE. M-1
    6. FF. M0
    7. GG. The code does not compile.
  8. 88. Which functional interfaces complete the following code, presuming variable r
    exists? (Choose all that apply.)

    6: ______ x = r.negate();
    7: ______ y = () -> System.out.println();
    8: ______ z = (a, b) -> a - b;
    1. AA. BinaryPredicate<Integer, Integer>
    2. BB. Comparable<Integer>
    3. CC. Comparator<Integer>
    4. DD. Consumer<Integer>
    5. EE. Predicate<Integer>
    6. FF. Runnable
    7. GG. Runnable<Integer>
  9. 99. Suppose you have a module named com.vet. Where could you place the following
    module-info.java file to create a valid module?

    public module com.vet {
    exports com.vet;
    }
    1. AA. At the same level as the com folder
    2. BB. At the same level as the vet folder
    3. CC. Inside the vet folder
    4. DD. None of the above
  10. 1010. What is the output of the following program? (Choose all that apply.)

    1: interface HasTail { private int getTailLength(); }
    2: abstract class Puma implements HasTail {
    3: String getTailLength() { return "4"; }
    4: }
    5: public class Cougar implements HasTail {
    6: public static void main(String[] args) {
    7: var puma = new Puma() {};
    8: System.out.println(puma.getTailLength());
    9: }
    10: public int getTailLength(int length) { return 2; }
    11: }
    1. AA. 2
    2. BB. 4
    3. CC. The code will not compile because of line 1.
    4. DD. The code will not compile because of line 3.
    5. EE. The code will not compile because of line 5.
    6. FF. The code will not compile because of line 7.
    7. GG. The code will not compile because of line 10.
    8. HH. The output cannot be determined from the code provided.

Informationen

Beschreibung
Use the following assessment test to gauge your current level of skill in Java
Sprache
Español
Aufrufe
270
Verlauf
Erstellt am 23 Sep 2022 · aktualisiert am 23 Sep 2022
Schlagwörter
informática
Bewertung
Noch keine Bewertungen
Bewerte dieses Quiz
Bewerte dieses Quiz

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck