Tag Archives: 1z1808
Given: class Overloading { int x(double d) { System.out.println("one"); return 0; } String x(double d)
Given:class Overloading {int x(double d) {System.out.println(“one”);return 0;}String x(double d) {System.out.println(“two”);return null;}double x(double d) {System.out.println(“three”);return 0.0;}public static void main(String[] args) {new Overloading().x(4.0);}}What is the result? A. Three B. One C. Two D. Compilation fails. Correct Answer: D
Given: (Exhibit) What is the result?
Given the code fragment: (Exhibit) What is the result?
Given: (Exhibit) Which statement is true?
Given: (Exhibit) And given the code fragment: (Exhibit) What is the result?
Given: class Base { public static void main(String[] args) { System.out.println("Base " + args[2]); }
Given: class Base {public static void main(String[] args) {System.out.println(“Base ” + args[2]);}}public class Sub extends Base{public static void main(String[] args) {System.out.println(“Overriden ” + args[1]);}}And the commands:javac Sub.javajava Sub 10 20 30What is the result? A. Overridden 20 B. Base 30 Overridden 20 C. Base 30 D. Overridden 20 Base 30 Correct Answer: A
The protected modifier on a Field declaration within a public class means that the field ______________.
The protected modifier on a Field declaration within a public class means that the field ______________. A. Can be read and written from this class and its subclasses defined in any package B. Can be read but not written from outside the class C. Can be read and written from this class and its subclasses only within the… Read More »
Which two are benefits of polymorphism?
Which two are benefits of polymorphism? A. Faster code at runtime B. More efficient code at runtime C. More dynamic code at runtime D. More flexible and reusable code E. Code that is protected from extension by other classes Correct Answer: B,D Reference:https://www.cs.princeton.edu/courses/archive/fall98/cs441/mainus/node5.html