Java Programming
Accenture 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

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

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.