Skip to content

Object Oriented Programming

CSE · Midterm · Fall 22

Paper 2 of 2By Md. Shefat Al MahmudSwitch

Paper 2 of 2

This browser can’t show the PDF here

Open it, and your phone’s PDF viewer takes it, or download it.

Read the questions as text

Read off the PDF by AI, so it may have mistakes. The PDF is the original.

Daffodil International University Department of Computer Science and Engineering Faculty of Science & Information Technology Midterm Examination, Fall 2022 Course Code: CSE 221/214, Course Title: Object Oriented Programming Level: 2 Term: 1+2 Batch: 59, 60, OLD-SYL Time: 01:30 Hrs Marks: 25 Answer ALL Questions [Optional] [The figures in the right margin indicate the full marks and corresponding course outcomes. All portions of each question must be answered sequentially.] 1 a) | What is the relationship between a class and an object? Explain with an example. | [2.5] | CO1 1 b) | Compare among the different Access Modifiers in Java. | [2.5] | CO1 2 a) | Suppose, your name is A, your father's name is B, and your grandfather's name is Z. You have two uncles named U1 and U2. C1 is the son of U2. Now, draw a UML and show the relationship between the classes. What types of inheritance it refers to? | [2.5] | CO2 2 b) | Explain how we can achieve polymorphism with examples. | [2.5] | CO2 3 a) | Suppose you want to write a program in Java. Consider a scenario where A, B, and C are three classes. The C class inherits A and B classes. If A and B classes have the same method name display() and you want to call this display() method from the "Child" class. Is this possible or not? Analyze your answer with appropriate examples. | [2.5] | CO3 3 b) | Suppose the parent class name is "Car" and child class name is "BMW". Parent class has a public method named "color()" that prints "Car color is red". Now apply the method overriding and print "BMW car color is black". | [2.5] | CO3 4 a) | Apply your knowledge of OOP to make the below class to exhibit fully encapsulation. You need to describe where to need change/correction step by step with your own words after completing code. public class Rectangle { int height; int width; int area; private void setHeight(int height) { this.height = height; } private void setWidth(int width) { this.width = width; } private void getHeight() { return height; } } | [5] | CO4 4 b) | Suppose you are given the following UML diagram. Now develop a Java Code to implement the UML Diagram. Create one object of this class and implement all the methods. [Figure: UML diagram of Doctor class with attributes name, id, hospital, phoneNo and methods setData, getName, getId, display, main] | [5] | CO4