Questions Related to technology

Multiple choice technology
  1. foreach( x ) System.out.println(z);

  2. for( int z : x ) System.out.println(z);

  3. while( x.hasNext() ) System.out.println( x.next() );

  4. for( int i=0; i< x.length; i++ ) System.out.println(x[i]);

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Multiple choice technology
  1. The code will compile without changes.

  2. The code will compile if public Tree() { Plant(); } is added to the Tree class.

  3. The code will compile if public Plant() { Tree(); } is added to the Plant class.

  4. The code will compile if public Plant() { this("fern"); } is added to the Plant class

  5. The code will compile if public Plant() { Plant("fern"); } is added to the Plant class.

Reveal answer Fill a bubble to check yourself
D Correct answer
Multiple choice technology
  1. java.lang.RuntimeException: Problem

  2. run.java.lang.RuntimeException: Problem

  3. End of method.java.lang.RuntimeException: Problem

  4. End of method.run.java.lang.RuntimeException: Problem

  5. run.java.lang.RuntimeException: ProblemEnd of method.

Reveal answer Fill a bubble to check yourself
D,E Correct answer
Multiple choice technology
  1. Compilation fails.

  2. An exception is thrown at runtime

  3. Synchronizing the run() method would make the class thread-safe.

  4. The data in variable "x" are protected from concurrent access problems.

  5. Declaring the doThings() method as static would make the class thread-safe.

  6. Wrapping the statements within doThings() in a synchronized(new Object()) { } block would make the classthread-safe.

Reveal answer Fill a bubble to check yourself
F Correct answer