Given: java
package vehicule.parent;
public class Car {
protected String brand = "Peugeot";
}
and java
package vehicule.child; import vehicule.parent.Car;
public class MiniVan extends Car { public static void main(String[] args) { Car car = new Car();
car.brand = "Peugeot 807"; System.out.println(car.brand);
}
}
What is printed?
Correct Answer:D
Which of the following statements is correct about a final class?
Correct Answer:C
Given: java
Runnable task1 = () -> System.out.println("Executing Task-1"); Callable
System.out.println("Executing Task-2"); return "Task-2 Finish.";
};
ExecutorService execService = Executors.newCachedThreadPool();
// INSERT CODE HERE
execService.awaitTermination(3, TimeUnit.SECONDS); execService.shutdownNow();
Which of the following statements, inserted in the code above, printsboth:
"Executing Task-2" and "Executing Task-1"?
Correct Answer:GH
Given: java
double amount = 42_000.00;
NumberFormat format = NumberFormat.getCompactNumberInstance(Locale.FRANCE, NumberFormat.Style.SHORT);
System.out.println(format.format(amount)); What is the output?
Correct Answer:D
Given: java
sealed class Vehicle permits Car, Bike {
}
non-sealed class Car extends Vehicle {
}
final class Bike extends Vehicle {
}
public class SealedClassTest { public static void main(String[] args) {
Class> vehicleClass = Vehicle.class; Class> carClass = Car.class; Class> bikeClass = Bike.class;
System.out.print("Is Vehicle sealed? " + vehicleClass.isSealed() + "; Is Car sealed? " + carClass.isSealed() +
"; Is Bike sealed? " + bikeClass.isSealed());
}
}
What is printed?
Correct Answer:C