Examlex

Solved

Which of the Following Class Definitions Is Correct in Java

question 41

Multiple Choice

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) ;
}
}


Definitions:

HIV

Human Immunodeficiency Virus, a virus that attacks the immune system and can lead to Acquired Immunodeficiency Syndrome (AIDS) if not treated.

Transmission

The process by which something is conveyed or carried from one place to another, often used in the context of diseases, mechanical power, or information.

High Fever

An elevated body temperature significantly above the normal range, often a sign of infection, inflammation, or other medical conditions.

Severe Headache

A headache of intense severity that can indicate serious health issues, such as migraine, high blood pressure, or brain disorders.

Related Questions