Given:
and the code fragment:
What is the result?
Correct Answer:B
Given the content:
and the code fragment:
What is the result?
Correct Answer:A
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?
Correct Answer:C
Given the code fragment:
You have been asked to define the ProductCode class. The definition of the ProductCode class must allow c1 instantiation to succeed and cause a compilation error on c2 instantiation.
Which definition of ProductCode meets the requirement?
Correct Answer:B
Given the code fragment:
Path file = Paths.get (“courses.txt”);
// line n1
Assume the courses.txt is accessible.
Which code fragment can be inserted at line n1 to enable the code to print the content of the courses.txt file?
Correct Answer:D
Given:
public class Test
public T get () { return t;
}
public void set (T t) { this.t = t;
}
public static void main (String args [ ] ) { Test
Test type 1 = new Test (); //line n1 type.set(“Java”);
type1.set(100); //line n2 System.out.print(type.get() + “ “ + type1.get());
}
}
What is the result?
Correct Answer:A