0% found this document useful (0 votes)
40 views2 pages

Java Assignment 1

The document outlines two Java assignments. The first involves creating Person, Student, and Teacher classes with getters and setters to store and retrieve information. It instructs to create objects of Student and Teacher, set their data using the setters, and get it back with the getters. The second assignment is to create a Calculator class with methods to add, subtract, multiply and divide integers, floats, doubles and strings, and test it by calling the methods from a main method.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views2 pages

Java Assignment 1

The document outlines two Java assignments. The first involves creating Person, Student, and Teacher classes with getters and setters to store and retrieve information. It instructs to create objects of Student and Teacher, set their data using the setters, and get it back with the getters. The second assignment is to create a Calculator class with methods to add, subtract, multiply and divide integers, floats, doubles and strings, and test it by calling the methods from a main method.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Assignment 1 : 

● Create ​
Person class​
 with following properties 
○ String firstName; 
○ String lasttName; 
○ int age; 
○ String address; 
 
○ setPersonInfo(String fName, String lName, int age, String address); 
// this function will set values to varibales 
 
○ getPersonInfo(); 
// this function will print data of each Personal class object 
 
● Create ​
class Student​
 which will extends Person class with following properties 
○ String standard;​  // eg. 1st, 2nd...  10th 
○ int rollNo; 
 
○ setStudentInfo(String fName, String lName, int age, String address, 
String standard, int rollNo);  
// this function will set values to varibales 
// call setPersonInfo() function inside setStudentInfo() to set values of 
firstName, lastName, age and address 
 
● getStudentInfo(); 
// this function will print data of each Student class object 
// call getPersonInfo() function inside getStudentInfo() 
 
 
● Create ​
class Teacher​
 which will extends Person class with following properties 
○ String[] Subjects; ​
 // Array of string which will store subject teached by that 
teacher 
○ int teacherNo; 
 
○ setTeacherInfo(String fName, String lName, int age, String address, 
String[] subjects, int teacherNo); 
// this function will set values to varibales 
// call setPersonInfo() function inside setTeacherInfo() to set values of 
firstName, lastName, age and address 
 
○ getTeacherInfo(); 
// this function will print data of each Teacher class object 
// call getPersonInfo() function inside getStudentInfo() 
 
 
● Create class School with main method into it. 
○ Inside main method create 1 object of Student class. 
○ Create 1 object of Teacher class. 
○ Set and get data for both the objects. 
 

Java Assignment 2: 
● Create class Calculator 
○ Add basic functionality of calculator Add, Sub, Multiply, divide. 
○ Above functionality should work on following data types: int, float, 
double,string. 
○ Create main class in calculator create one object of it and call these functions 
with different data. 
 
 

You might also like