nerdexam
Oracle

1Z0-819 · Question #92

1Z0-819 Question #92: Real Exam Question with Answer & Explanation

The correct answer is A. Move the entire Student class declaration to a separate Java file, Student.java. E. Change line 3 to static Student student;. See the full explanation below for the reasoning.

Question

public class Main { class Student { String classname; Student(String classname) { this.classname = classname; } } public static void main(String[] args) { Student student = new Student(); // line 1 Student classname = new Student(); // line 2 this.classname = classname; // line 3 } public static void main(String[] args) { var student = new Student("Biology"); // line 3 } } Which two independent changes will make the Main class compile? (Choose two.)

Options

  • AMove the entire Student class declaration to a separate Java file, Student.java.
  • BChange line 2 to public Student(String classname).
  • CRemove this.classname = classname;
  • DChange line 3 to Student student = new Student("Biology").
  • EChange line 3 to static Student student;

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice