Question:

What is a class ?

Answer:

A class is the generic definition of what an object is. A Class describes all the attributes of the object, as well as the methods that implement the behavior of the member object. In other words, class is a template of an object. For ease of understanding a class, we will look at an example. In the class Employee given below, Name and Salary are the attributes of the class Person. The Setter and Getter methods are used to store and fetch data from the variable.

public class Employee
{
private String name;
private String Salary;
public String getName()
{
  return name;
}
public void setName(String name)
{
  this.name = name; 
}
public String getSalary ()
{
  return Salary;
}
public void setSalary (String Salary)
{
  this. Salary = Salary;
}
} 

Keywords:

© 2017 QuizBucket.org