nerdexam
Oracle

1Z0-811 · Question #36

1Z0-811 Question #36: Real Exam Question with Answer & Explanation

Sign in or unlock 1Z0-811 to reveal the answer and full explanation for question #36. The question stem and answer options stay visible for context.

Object-Oriented Programming Principles

Question

Given: class Bus { String type = "default"; // line n1 Bus (String type) { // line n2 this.type = type; } } public class App{ public static void main(String[] args) { Bus b1 = new Bus(); System.out.println(b1.type); Bus b2 = new Bus("luxury"); System.out.println (b2.type); } } What is the result?

Options

  • AThe code fails to compile. To make it compile, at line n1 insert: this() {}
  • BThe code fails to compile. To make it compile, at line n2 insert: this();
  • CThe code fails to compile. To make it compile, at line n1 insert: Bus() {}
  • DThe code compiles and prints: default luxury

Unlock 1Z0-811 to see the answer

You've previewed enough free 1Z0-811 questions. Unlock 1Z0-811 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#constructors#default constructor#constructor overloading#object instantiation
Full 1Z0-811 Practice