Which of the following class definitions is correct in Java? (i) public class Employee {private String name; private double salary; private int id; public Employee() {name = ""; salary = 0.0; id = 0;} public Employee(String n, double s, int i) {name = n; salary = s; id = i;} public void print() {System.out.println(name + " " + id + " " + salary) ;}} (ii) public class Employee {private String name; private double salary; private int id; public void Employee() {name = ""; salary = 0.0; id = 0;} public void Employee(String n, double s, int i) {name = n; salary = s; id = i;} public void print() {System.out.println(name + " " + id + " " + salary) ;}}
A) Only (i)
B) Only (ii)
C) Both (i) and (ii)
D) Neither is correct
Correct Answer:
Verified
Q25: Q26: In Java, the reference this is used Q27: Constructors have the same name as the Q28: Consider the following class definition. public class Q29: A mutator method of a class changes Q31: In _ copying, each reference variable refers Q32: Consider the following statements. public class Circle Q33: Consider the following class definition. public class Q34: Which of the following is used to Q35:
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents