You are on page 1of 3

Mid Term Dated:31/05/21

Total Marks: 20
Object Oriented Programming Time Allowed:
Session 2020-2024 90 Minutes
Roll Number Name Section

____________ ____________________________________________ ______________

Question NO. 1 – 10 Maks


A. By passing object in “System.out.println()” statement prints the reference of the
object e.g
Student st=new Student();
System.out.println(st)

What measures has be taken if the requirement is to print the state/data of the
object the instead reference ? (2)

B. What are components of class diagram, Draw a class diagram representing


composition and Inheritance such that Employee Class is composed of Date Class
and Contract Employee is inherited from Employee Class. Use appropriate fields
and methods. (1)

C. Why the Iterator is used? What are alternative to Iterators? (1)

D. What is java virtual machine, briefly describe (1)

E. A setter method is also called ________________ method. (1)


a. Accessor
b. Mutator
c. Public
d. Private

F. What will be the output of following program (1)


class Abc{

int id;

Public Abc(int id){


id = id;
}

public void getId(){


return id;
}
Mid Term Dated:31/05/21
Total Marks: 20
Object Oriented Programming Time Allowed:
Session 2020-2024 90 Minutes
Roll Number Name Section

____________ ____________________________________________ ______________

Public class Test{


Public static void main(String args[]){
Abc a = new Abc(9);
System.out.println(a.getId());
}
}

G. What is purpose of “this” keyword in Java (1)

H. What is constructor overloading (1)

I. What is Encapsulation (1)

Question 2 - (5+5=10 Marks)


Consider the following class:
public class Student
{
private String name;
private double marks;
public Student(String name, double marks)
{
this.name=name;
this.marks=marks;
}
public String getName()
{
return(name);
}
Mid Term Dated:31/05/21
Total Marks: 20
Object Oriented Programming Time Allowed:
Session 2020-2024 90 Minutes
Roll Number Name Section

____________ ____________________________________________ ______________

public double getMarks()


{
return(mark);
}
public void toString()
{
System.out.println("Name="+ name);
System.out.println("Marks="+ marks);
}

Write another class with name “EnteryTestList” having the following attributes/ Fields:
A Hashmap with name MeritList<key, Value> pair, whereas key the shall be rollno
with data type shall“Integer” and value data type shall be of “Student” type(above
class).
(i) Write a method “addStudent” with following signature. (5)
Void addStudent( int rollno, String name, String marks):
Method should add the student object (Anonymous object) in as value and key
would be rollno.
(ii) Write a method “generateMeritList” with following signature
Public void generateMeritLit( int merit) (5)

Method shall iterate the HasMap “MeritList” as created in previous method


and display those students name and marks whose marks are greater than or
equal to “merit” passed in parameter.

---------------------------------------------Good Luck-------------------------------------------------

You might also like