Java Programming
Accenture Technical PrimereasyJava Programming03 Class And Objects, Date Api

Accenture Java Programming Practice Question

Observe the below code. public class Student { private int id; private String name; private char grade; //Constructor 1 public Student() { id=0; name= " "; } //Constructor 2 public Student(int id, String name) { this.id=id; this.name=name; } } Choose the constructor that is invoked, when an object is created as shown below. new Student(); Constructor 1 new Student(54, "John"); Constructor 2

Answer options

A
public class Student { private int id; private String name; private char grade; //Constructor 1 public Student() { id=0; name= " "; } //Constructor 2 public Student(int id, String name) { this.id=id; this.name=name; } } Choose the constructor that is invoked, when an object is created as shown below. new Student(); Constructor 1 new Student(54, "John"); Constructor 2
B
public class Student { private int id; private String name; private char grade; //Constructor 1 public Student() { id=0; name= " "; } //Constructor 2 public Student(int id, String name) { this.id=id; this.name=name; } } Choose the constructor that is invoked, when an object is created as shown below. new Student(); [Constructor 1] new Student(54, "John"); [Constructor 2]

Correct answer: public class Student { private int id; private String name; private char grade; //Constructor 1 public Student() { id=0; name= " "; } //Constructor 2 public Student(int id, String name) { this.id=id; this.name=name; } } Choose the constructor that is invoked, when an object is created as shown below. new Student(); Constructor 1 new Student(54, "John"); Constructor 2

Explanation

Quick AnswerThe correct answer is public class Student { private int id; private String name; private char grade; //Constructor 1 public Student() { id=0; name= " "; } //Constructor 2 public Student(int id, String name) { this.id=id; this.name=name; } } Choose the constructor that is invoked, when an object is created as shown below. new Student(); Constructor 1 new Student(54, "John"); Constructor 2 because it directly addresses the core logic of Java Programming.

Correct answer: public class Student { private int id; private String name; private char grade; //Constructor 1 public Student() { id=0; name= " "; } //Constructor 2 public Student(int id, String name) { this.id=id; this.name=name; } } Choose the constructor that is invoked, when an object is created as shown below. new Student(); Constructor 1 new Student(54, "John"); Constructor 2.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerPrep has 1400+ practice questions, 2026 simulations and coding hands-on — all free.

Watch Walkthroughs!