20201BCA0067 OOP Lab 9 Record
20201BCA0067 OOP Lab 9 Record
Submitted by
Name: SYEDA FARHEEN
Roll No: 20201BCA0067
Laboratory Instructor
Mr.B. Prabhu Shankar
Aim:
Write a java program to store home address and office address without
overriding.
Problem Statement:
A delivery boy is talking to the customer who is working in one organization. The
delivery boy wants to know the address to deliver the product. Then the
customer is giving the address of both organization and home address. The
delivery boy wants to store these address in his application but there is only one
column. Help him to store both addresses without override the values.
Theory:
Inheritance in Java is a mechanism in which one object acquires all the
properties and behaviours of a parent object. It is an important part of
OOPs (Object Oriented programming system).
Reasons for using Inheritance:- o For Method Overriding (so runtime
Procedure:
1. Define all the required classes.
2. Take input from the user for home’s address and offices’ address.
3. Create and initialize objects.
4. Display the required output.
Tools Used:
System.out.println("Rajankunte,Bangalore");
System.out.println("Jakkur,Bangalore");
main(String args[]){
h.address();
c.address();
Output:
Test case 1
Jakkur, Bangalore
Rajankunte, Bangalore
Test case 2
Gandhidham, Kutch
Adipur, Kutch
Output Screenshots:
Test Case 1
Test Case 2
Result:
Aim:
Write a java program to share the marks without providing the students to edit
it.
Problem Statement:
A teacher is having marks list of her students. One of the student is asked to
share his marks. She is worrying that if she shared the marks to the student he
may edit. So help her to share the marks without editing.
Theory:
The final keyword in java is used to restrict the user. The java final keyword can
be used in many context. Final can be:
1. variable
2. method
3. class
The final keyword can be applied with the variables, a final variable that have no
value it is called blank final variable or uninitialized final variable. It can be
initialized in the constructor only. The blank final variable can be static also which
will be initialized in the static block only. We will have detailed learning of these.
Let's first learn the basics of final keyword.
Procedure:
1. Define all the required classes and variables.
2. Call the method so as to display the marks without editing it further.
3. Print the desired output. Tools Used:
Online java compiler
marks=36; void
show(){
System.out.println("List of marks");
void show(){
System.out.println("Student:"+marks);
main(String args[]){
t.show();
s.show();
Output:
Test Case 1 List
of marks
Student:36
Test case 2
List of marks
Student:57
Output Screenshots:
Test Case 1
Test Case 2
Result: