You are on page 1of 8

Lab 5

Task 1:
Write a constructor in the Car class given below that initializes the brand class field with the
string “Ford”. Call the getBrand() method in the main method of the Sample class and store
the value of the brand in a variable, and print the value.
Source code:

Output:

Task 2:

1
Create a class named circle and construct three circle objects with radius 10,10.2,12.0 and
display the radius and area of each circle. A no argument constructor set the value of radius to
1. A getArea() function used to return the area of circle.
Source code:

Output:

Task 3:

2
Write a program that illustrate the parameterized constructor and print students details like
name, id, GPA.
Source code:

Output:

Task 4:
Write a Java program to create a class called "Airplane" with a flight number, destination, and
departure time attributes, and methods to check flight status and delay.

3
Source code:

Output:

Task 5:
Write a program with a method named getTotal that accepts two integers as an argument and
return its sum. Call this method from main( ) and print the results.(use of constructor is must.)

4
Source code:

Output:

Task 6:
Write a Java program to create a class called "Inventory" with products and methods to add
and remove products, and to check for low inventory.
Source code:

5
Output:

Task 7:

6
Write a Java program to create a class called "Movie" with attributes for title, director, actors,
and reviews, and methods for adding and retrieving reviews.
Source code:

Output:

Task 8:
Write a Java program to create a class called "Restaurant" with attributes for menu items,
prices, and ratings, and methods to add and remove items, and to calculate average rating

7
Source code:

Output:

You might also like