Given:
and the code fragment:
Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?
Given:
interface Doable {
public void doSomething (String s);
}
Which two class definitions compile? (Choose two.)
You want to create a singleton class by using the Singleton design pattern.
Which two statements enforce the singleton nature of the design? (Choose two.)
Given:
and the command:
java Product 0
What is the result?
Given:
and the code fragment:
What is the result?
Given:
class FuelNotAvailException extends Exception { }
class Vehicle {
void ride() throws FuelNotAvailException {//line n1
System.out.println(“Happy Journey!”);
}
}
class SolarVehicle extends Vehicle {
public void ride () throws Exception {//line n2
super ride ();
}
}
and the code fragment:
public static void main (String[] args) throws FuelNotAvailException, Exception {
Vehicle v = new SolarVehicle ();
v.ride();
}
Which modification enables the code fragment to print Happy Journey!?
Given the Greetings.properties file, containing:
and given:
What is the result?
Given the code fragment:
What is the result?
You have been asked to create a ResourceBundle which uses a properties file to localize an application.
Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu?
Given the code fragment:
public void recDelete (String dirName) throws IOException {
File [ ] listOfFiles = new File (dirName) .listFiles();
if (listOfFiles ! = null && listOfFiles.length >0) {
for (File aFile : listOfFiles) {
if (!aFile.isDirectory ()) {
if (aFile.getName ().endsWith (“.class”))
aFile.delete ();
}
}
}
}
Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.
What is the result?
Given the records from the STUDENT table:
Given the code fragment:
Assume that the URL, username, and password are valid.
What is the result?
Which two statements are true about synchronization and locks? (Choose two.)
Given the code fragment:
Map
books.put (1007, “A”);
books.put (1002, “C”);
books.put (1003, “B”);
books.put (1003, “B”);
System.out.println (books);
What is the result?
Given:
interface Rideable {Car getCar (String name); }
class Car {
private String name;
public Car (String name) {
this.name = name;
}
}
Which code fragment creates an instance of Car?
Given:
What is the result?
Given the code fragment:
List
values.stream ()
.map(n -> n*2)//line n1
.peek(System.out::print)//line n2
.count();
What is the result?
Given the code fragments:
and
What is the result?
Given:
public class Canvas implements Drawable {
public void draw () { }
}
public abstract class Board extends Canvas { }
public class Paper extends Canvas {
protected void draw (int color) { }
}
public class Frame extends Canvas implements Drawable {
public void resize () { }
}
public interface Drawable {
public abstract void draw ();
}
Which statement is true?
and the code fragment?
What is the result?
Given the code fragment:
What is the result?
Given:
and the code fragment:
Which modification enables the code fragment to print Speaker?
Given:
What is the result?
Given the content of /resourses/Message.properties:
welcome1=”Good day!”
and given the code fragment:
Properties prop = new Properties ();
FileInputStream fis = new FileInputStream (“/resources/Message.properties”);
prop.load(fis);
System.out.println(prop.getProperty(“welcome1”));
System.out.println(prop.getProperty(“welcome2”, “Test”));//line n1
System.out.println(prop.getProperty(“welcome3”));
What is the result?
Given:
public class Counter {
public static void main (String[ ] args) {
int a = 10;
int b = -1;
assert (b >=1) : “Invalid Denominator”;
int с = a / b;
System.out.println (c);
}
}
What is the result of running the code with the –ea option?
Given the code fragment:
BiFunction
//line n2
System.out.println(val.apply(10, 10.5));
What is the result?
Given the code fragment:
LocalDate valentinesDay =LocalDate.of(2015, Month.FEBRUARY, 14);
LocalDate next15days = valentinesDay.plusDays (15);
LocalDate nextYear = next15days.plusYears(1); // line n1
System.out.println(nextYear);
What is the result?
Given the code fragment:
What is the result?
Given:
class Vehicle {
int vno;
String name;
public Vehicle (int vno, String name) {
this.vno = vno,;
this.name = name;
}
public String toString () {
return vno + “:” + name;
}
}
and this code fragment:
Set
vehicles.add(new Vehicle (10123, “Ford”));
vehicles.add(new Vehicle (10124, “BMW”));
System.out.println(vehicles);
What is the result?