7.8. Sample exam questions
What is the output of the following code:
class Course { String courseName; Course() { Course c = new Course(); c.courseName = "Oracle"; } } class EJavaGuruPrivate { public static void main(String args[]) { Course c = new Course(); c.courseName = "Java"; System.out.println(c.courseName); } }
- The code will print Java.
- The code will print Oracle.
- The code will not compile.
- The code will throw an exception or an error at runtime.
Select the correct option(s):
- You cannot handle runtime exceptions.
- You should not handle errors.
- If a method throws a checked exception, it must be either handled by the method or specified in its throws clause.
- If a method throws a runtime exception, it may include the ...
Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.