0% found this document useful (0 votes)
5 views3 pages

CSE1115 Mid 183

The document is a mid-term exam paper for the Object-Oriented Programming course at United International University, covering various Java programming tasks and concepts. It includes questions on array manipulation, class creation, error fixing in code, and the implementation of abstract classes. The exam consists of multiple programming problems, each with specific requirements and expected outputs.

Uploaded by

Tanvir
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)
5 views3 pages

CSE1115 Mid 183

The document is a mid-term exam paper for the Object-Oriented Programming course at United International University, covering various Java programming tasks and concepts. It includes questions on array manipulation, class creation, error fixing in code, and the implementation of abstract classes. The exam consists of multiple programming problems, each with specific requirements and expected outputs.

Uploaded by

Tanvir
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/ 3

United International University (UIU)

Dept. of Computer Science and Engineering (CSE)


MID TERM EXAM :: FALL 2018
Course Code: CSI 211 Course Title: Object-Oriented Programming
Date: 22/11/18 Total Marks: 30 Time: 1 Hour 45 mins

1. a) Write a Java program that will go through the items of an array and find the min value using enhance for [2]
loop. Take the following values as the initial values of the array {2, 3, 9, 8, 13, 1, 5, 19, 15}

b) What is the difference between following two declarations in Java?


[1]
i. int c [ ], x
ii. int [ ] c, x

c) Write a code fragment to create the following multidimensional integer array.


[2]

2. a) Consider the following MovieTheater class. Now, write a Movie class in such a way that MovieTheater [3]
class will give expected output as shown below.
Code Output
public class MovieTheater { Playing: Debi [2018]
public static void main(String[] args) { Playing: Venom [2018]
Movie m_Debi = new Movie("Debi", 2018, "1hr 30min"); Movie name: Debi, year: 2018, Duration: 1hr 30min
Movie m_Venom = new Movie ("Venom", 2018, "1hr");

m_Debi.play();
m_Venom.play();
Movie.movieInfo(m_Debi);
}
}

b) Find out if the following JAVA programs have any error. Fix the code and rewrite. You cannot delete [2]
any line of code. However, you are allowed to edit or add any code as per requirement.
public class Simple { public class Test {
static int a=5; public static void main(String[] args) {
int b=6; Simple s=new Simple();
private int #x=5; Simple.sum();
private int data=100; System.out.println(s.data);
static void sum(){ }
System.out.println(a+b); }
}
}

3. a) Write a class Grader which has three attributes: name, id and payPerAssignment. The constructor of [4]
Grader class initializes name, id and payPerAssignment with this reference keyword. There is one method
named void printEarnings() which prints the earning of grader by multiplying the number of graded
assignments with per-assignment-pay. To do so, you should include one private instance variables in Grader
class definition: count. Use getter and setter methods in the class to set and get the values of the field.

Page 1 of 3
b) What is the difference between static binding and dynamic binding? [1]

4 a) Fix the following code and rewrite the correct one. [4]
class B extends A{
class A{ private int bi;
private int ai;
public B(){}
public A(int ai){ this.ai = ai; } public B(int bi){
this(0, bi);
void set(){ }
this.ai = 0;
} void set(){
void set(int ai){ ai = 0;
this.ai = ai; bi = 0;
} }
} void set(intai, int bi){
this.ai = ai;
this.bi = ai;
}
}

b) Write the output of the following code. [1]

public class Child extends Parent{


public class Parent { Child()
Parent() {
{ System.out.println("Child Class");
System.out.println("Parent Class"); }
}
} public static void main(String[] args) {
Child c=new Child();
}
}

5. Suppose you are hired by a company to make them a java program that calculates each employee’s monthly [5]
salary. You decided to write an abstract class named Employee which has name and age as member variables
and calculateMonthlySalary() as abstract member function. There are two other concrete classes named
DailySalariedEmployee and HourlySalariedEmployee. Both of these classes are subclass of Employee class.
DailySalariedEmployee has a member variable dailySalary and HourlySalariedEmployee has a member
variable hourlySalary.

Now, write each of the classes (Employee, DailySalariedEmployee, HourlySalariedEmployee). You should
write appropriate constructors that initialize the member variables. There are 22 working days and 176 working
hours in a month.

Page 2 of 3
6. a) Write the output of the given code. [3]
public class Application {
public static void main(String[] args) {
public class Wizard { Wizard w1=new Wizard("Hagrid");
String name; Wizard w2=new Wizard("Sirius");
Wizard(String n) Wizard w3=new Wizard("Harry");
{
name=n; w1=w2;
} w2=w3;
} w3=w1;

System.out.println(w1.name);
System.out.println(w2.name);
System.out.println(w3.name);
}
}

b) Write the output of the given code. [2]


public class FindOutput {
public class Example { public static void main(String[] args) {
static int a=5; Example e1=new Example();
int b=10; Example e2=new Example();
}
e1.a=10;
e1.b=30;

System.out.println(e2.a);
System.out.println(e2.b);
System.out.println("Sum: "+2+3);
System.out.println('a'+2);
}
}

Page 3 of 3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy