0% found this document useful (0 votes)
62 views8 pages

20201BCA0067 OOP Lab 9 Record

The document describes an Object Oriented Programming lab report submitted by Syeda Farheen for their BCA degree. It includes two programming exercises: 1) A program to store home and office addresses without overriding using inheritance. It defines Home and Office classes that both call an address method to display the addresses. 2) A program to share a student's marks without allowing them to be edited using the final keyword. It defines Teacher and Student classes where the marks variable is final to prevent changes. Both classes call a show method to output the marks.

Uploaded by

syeda farheen
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)
62 views8 pages

20201BCA0067 OOP Lab 9 Record

The document describes an Object Oriented Programming lab report submitted by Syeda Farheen for their BCA degree. It includes two programming exercises: 1) A program to store home and office addresses without overriding using inheritance. It defines Home and Office classes that both call an address method to display the addresses. 2) A program to share a student's marks without allowing them to be edited using the final keyword. It defines Teacher and Student classes where the marks variable is final to prevent changes. Both classes call a show method to output the marks.

Uploaded by

syeda farheen
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/ 8

Object Oriented Programming (BCA202)

An Object Oriented Programming Lab report submitted in


partial fulfillment of the requirements for the degree of BCA

Submitted by
Name: SYEDA FARHEEN
Roll No: 20201BCA0067

Laboratory Instructor
Mr.B. Prabhu Shankar

Department of Computer Science and Engineering


PRESIDENCY UNIVERSITY, BANGALORE
Karnataka- 560064, India
DATE:
18.09.21
STORING THE ADRESSES WITHOUT OVERRIDING
EX.NO: 9.1

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

polymorphism can be achieved). o For Code Reusability.

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:

Online java compiler


Source code: import

java.util.*; class Office{

public void address(){

System.out.println("Rajankunte,Bangalore");

class Home extends Office{

public void address() {

System.out.println("Jakkur,Bangalore");

public class Main{ public static void

main(String args[]){

Home h=new Home();

Office c=new Office();

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:

Thus, the above Java Program successfully implemented and executed.


DATE:
18.09.21
STUDENTS’ MARK LIST
EX.NO: 9.2

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:

Final Keyword in JAVA:-

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

Source code: class

Teacher{ final int

marks=36; void

show(){

System.out.println("List of marks");

class Student extends Teacher{

void show(){

System.out.println("Student:"+marks);

public class Main{ public static void

main(String args[]){

Teacher t=new Teacher();

Student s=new Student();

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:

Thus, the above Java Program successfully implemented and executed.

You might also like