OOP - Lab Task-5 - Methods - UML To JAVA Code

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Lab Task – 5

Methods in JAVA (Solve Any 2)

1. Make a simple calculator using four methods (addition, subtraction, multiplication


and division). Each Method will receive the arguments and will return the result.
[No-Static Method]

2. Find the area of a Circle. Write a method which will receive the radius as argument
and then will return the area. [non-static method]

3. Write a method named maxValue() which will find out the maximum value from two
integer numbers. [Static method with argument and return value]

4. Write a method named maxValue() which will find out the maximum element from an
Array. [Static method with argument and return value]

UML to JAVA Code (Solve Any 2)

1. Create the Student Class. Then create two objects of this class. Take User input for the
instance variables.

Student
-name: String
-id: int
-cgpa: double

+insertRecord (String , int , double) : void


+displayRecord():void
+main(String[]) :void

Page 1 of 3
2. Create the Student Class. Then create N Number objects of this class. Take User input
for the instance variables.

Student
-name: String
-id: int
-cgpa: double

+main(String[]) :void

3. Create the Student Class. Then create N number of objects of this class. Take User
input for the number of objects and the instance variables [Array of Objects].

Student
-name: String
-id: int
-cgpa: double

+insertRecord (String , int , double) : void


+displayRecord():void
+main(String[]) :void

Page 2 of 3
Home Work
1. Unsolved Problems from the Lab Task - 5.

2. Suppose you are going to start your own company. You need to recruit some employees.
Now, create a class named “Employee” to store the information of them. Convert the
following UML into Java code and store information of three employees.

Employee

-name: String
-id: String
-age: int
-salary: double

+setEmpNameId(String ,String) : void


+setEmpAge(int) : void
+setEmpSalary(double) : void
+display_Info():void
+main(String) : void

Page 3 of 3

You might also like