Object Oriented Programming Assignment: Concepts and Implementation, Exercises of Object Oriented Programming

This document contains the assessment questions for the object oriented concepts for the course.

Typology: Exercises

2018/2019

Uploaded on 02/28/2019

swtooba11
swtooba11 🇵🇰

5

(1)

2 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Assignment # 01 [20 Marks]
Subject: Object Oriented Programming
Question no 01: [05 Marks]
Give reasons to support the the following statments.
1. Java is plateform indepentdent.(01 marks)
2. Object oriented programming approach is more recommended than procedural programming approach. (01
marks)
3. Suppose the following code:
package test;
class Test {
int x, y;
}
package main;
class Main {
public static void main(String args[]) {
Test t = new Test();
System.out.println(t.x + " " + t.y);
}
}
The variables x and y of Test class are not visible to Main class. (01 marks)
4. Suppose the following code:
class Main {
public static void main(String args[]) {
System.out.println(fun());
}
int fun() {
return 20;
}
}
The fun() method is not accessible to Main class. Also what are the possible solution to make is accessible. (02 marks)
Question no 03: [05 Marks]
pf2

Partial preview of the text

Download Object Oriented Programming Assignment: Concepts and Implementation and more Exercises Object Oriented Programming in PDF only on Docsity!

Assignment # 01 [20 Marks]

Subject: Object Oriented Programming

Question no 01: [05 Marks]

Give reasons to support the the following statments.

1. Java is plateform indepentdent.(01 marks)

2. Object oriented programming approach is more recommended than procedural programming approach. (

marks)

3. Suppose the following code:

package test; class Test { int x, y; }

package main; class Main { public static void main(String args[]) { Test t = new Test(); System.out.println(t.x + " " + t.y); } }

The variables x and y of Test class are not visible to Main class. (01 marks)

4. Suppose the following code:

class Main { public static void main(String args[]) { System.out.println(fun()); } int fun() { return 20; } }

The fun() method is not accessible to Main class. Also what are the possible solution to make is accessible. (02 marks)

Question no 03: [05 Marks]

Suppose Hospital management system. In hospital, many objects are involved such as person, patient, staff, and many

departments. The Person class is used to store the information of persons including id, name, birthdate, address, and

gender. The person class has two child named staff and patient. The staff class includes joiningdate, and education. The

patient class includes accepteddate, and prescription. All three class has method named “displayDetail” to show the

complete record.

You are required to build UML class diagram for the above scenario.

Question no 04: [10 Marks]

a. What is an encapsulation? What are the benefit for using encapsulation? (02 marks)

b. Write an interactive program to implement the scenario given in question 3. Use proper constructor to instantiate

the object of each class.(05 marks)