Skip to content

Object Oriented Programming

CSE · Midterm · Spring 22

Section ALL

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 and Information Technology Midterm Examination Semester: Spring 2022 Course Code: CSE221/214 (DAY) Course Title: Object Oriented Programming Level: 2 Term: 1 Section: ALL Time: 1.5 hrs. Full Marks: 25 Question: 1 [Marks: 5] [Figure: A UML class diagram containing classes Eye, Person, Brain, Heart, Employe (Employee), Owner, and Company with various variables, methods, and relationships.] a. Identify the Variables, Classes, Methods and Constructors from the above UML Diagram. [2.5] b. Also identify what types of relationships are present between classes. [2.5] Question: 2 [Marks: 5] a. Rahim has written the code like below. But it is showing compile time error. Can you identify what mistake he has done? [2.5] public class Aa{ //Class Aa Members } public class Bb{ //Class Bb Members } public class Cc extends Aa, Bb{ //Class Cc Members } b. What do you mean by the concept of polymorphism in OOP? [2.5] Question: 3 [Marks: 5] a. Last week, you and your father had gone to the Ekushey Boi Mela 2022. In the fair, you met your uncle and his two sons. After buying some books you planned to visit your grandfather who lives in Mirpur. Suppose, your name is X, you father's name is Y, and your grandfather's name is Z. Your uncle's name is U and his sons' names are C1 and C2. Now, draw a UML and show the relationship. What types of inheritance it refers? [2.5] b. What is the difference between Aggregation and Composition? [2.5] Question: 4 [Marks: 10] public class Student { private String sName; private int sId; private String dept; public Student(String sName, int sId, String dept) { this.sName = sName; this.sId = sId; this.dept = dept; } } public class MyTestClass { public static void main(String[] args) { Student st = new Student(); System.out.println("Name: "+st.sName); System.out.println("ID: "+sId); System.out.println("Department: "+st.dept); } } Consider the above two classes named "Student" and "MyTestClass". The following output is expected from the given java program. Your task is to rewrite the code with necessary changes to find out the solution for the expected outputs without changing the access modifier of the attributes used in "Student" class. Expected Output: Name: Akash ID: 130 Department: CSE