1Z0-829 Utilizing Java Object-Oriented Approach • 10 Questions
10 1Z0-829 Utilizing Java Object-Oriented Approach practice questions with answers and explanations. Free, no signup.
Refer to the exhibit. Two Java classes are defined as shown. What is the output when the Sub class is executed?
Refer to the exhibit.
public class Main {
public static void main(String[] args) {
System.out.println("Hello");
}
}
And the command:
$ javac Main.java
$ java Main
Output:
Hello
Now consider this class in another file:
public class Sub extends Main {
public static void main(String[] args) {
System.out.println("World");
}
}
Compiled and run:
$ java Sub
What is the output?