write java program to create a class call person with nage and age attribute create
two instance of the person class set their attributes using constructed and print
their name and age
ANS:
import [Link].*;
class person{
String name;
int age;
public person(String name,int age){
[Link] = name;
[Link] = age;
}
public static void main(String[] args){
Scanner sc = new Scanner([Link]);
[Link]("enter your Name: ");
String name = [Link]();
[Link]("enter your age: ");
int age = [Link]();
person person = new person(name,age);
[Link]("Name: "+[Link]);
[Link]("age: "+[Link]);
}
}
write a java program to create aclass cale book with attributes for title,uthor and
ISBN also create method to add and remove books
ANS:
import [Link].*;
class Book{
String title;
String author;
int isbl;
public Book(String title,String author,int isbl){
[Link] = title;
[Link] = author;
[Link]=isbl;
}
public static void main(String[] args){
Scanner sc = new Scanner([Link]);
[Link]("enter title Of the book: ");
String title = [Link]();
[Link]("enter author of the book: ");
String author= [Link]();
[Link]("enter isbl: ");
int isbl = [Link]();
Book book = new Book(title, author,isbl);
[Link]("title: "+[Link]);
[Link]("author: "+[Link]);
[Link]("ISBL: "+[Link]);
}
}
public remove element("book"){
write a java program tocreate a class employee with name joitle and salary
attributes and methods to calculate and update the salary