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


Answer: A

Computer Science & Information Technology

You might also like to view...

_________ is a logical unit of the computer that coordinates the activities of all the other logical units.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Which of the following is an exception to copyright protection?

A. copyright infringement B. cyberlaw C. fair use D. intellectual property

Computer Science & Information Technology

Using wildcard metacharacters, how can one indicate a number is either 1, 2, 3, or 4?

A. 1-4 B. [1-4] C. [1234] D. [1,2,3,4]

Computer Science & Information Technology

Email is one of the main ways to distribute viruses and malware

Indicate whether the statement is true or false.

Computer Science & Information Technology