You are on page 1of 4

Sr.

No:

Roll Number
MID-SEMESTER EXAMINATION, 2020-21
Fifth Semester

CS504A – Object Oriented Programming using Java

Time: 2 Hrs Maximum Marks: 30


Instructions to the candidate:
 Figures to the right indicate full marks.
 Draw neat sketches and diagram wherever is necessary.

Part - A
Attempt all (5) Questions from the following 05*2=10 Marks

Q. Question Mark
No s
1. Which of the following declarations does not compile? Class (2)
(a) double num1, int num2 = 0;
(b) int num1, num2;
(c) int num1, num2 = 0;
(d) int num1 = 0, num2 = 0;
2. Which statement about a valid .java file is true? (2)
(a)  It may define at most one public class.
(b)  It can only contain one class declaration.
(c) It can contain one pulic class declaration and one public interface
definition.
(d) It must define at least one public class.
3. Which is correct about an instance variable of type String? (2)
a) It defaults to null.
b) It defaults to an empty string.
c) It does not have a default value.
d) It will not compile without initializing on the declaration line
4. (2)
What is true of the finalize() method?

JIS UNIVERSITY, SPRING 2021 Page 1 of 4


Sr. No:

(a). It may be called zero or one times.


(b). It may be called zero or more times.
(c). It will be called exactly once.
(d). It may be called one or more times.

5. (2)
How do you force garbage collection to occur at a certain point?

(a). None of the above


(b). Call System.gc()
(c). Call System.requireGc()
(d). Call System.forceGc()

Part - B
Attempt any Two (2) Questions from the following 2*5=10 Marks

Q. Question Marks
No
6. a) (2+2
Write java program(s) to explain the concept of =4)
aggregation and composition?

b) (1)

What is the difference between aggregation and


composition?

7. a) (2)
Write a java program to explain the concept of inner
class?

b) (1)
What are the different types of inner class in java?

JIS UNIVERSITY, SPRING 2021 Page 2 of 4


Sr. No:

c) Can we override inner class? – justify your answer (2)

8. a) How the garbage collector works in Java and how (3)


can we invoke garbage collector?
b) (2)
Write a java program to explain the concept of
constructor chaining?

Part - C
Attempt the Question from the following 1*10=10 Marks
Analytical/Numerical based/Case Study/Application oriented/Higher order Thinking Level of
Questions Only

Q. Question Marks
No
9. a) (2+3+2+
What is difference between Heap and Stack 3 = 10)
Memory in java? Write a java program to show the
difference between the Inner Class and Sub Class?
What is static loading and dynamic class loading?
Write a java program to show static
polymorphism?

b) Write a java program to explain immutable object? (3+2+2+


How a no – argument constructor is different from 3 =10)
default Constructor? Write the purpose of
Runtime class and System class?

What would be the outcome of following Java


coding snippet?

class TestA {

public static void main(String[] args) {

for (int index = 0; 1; index++) {

JIS UNIVERSITY, SPRING 2021 Page 3 of 4


Sr. No:

System.out.println("Welcome");

break;

JIS UNIVERSITY, SPRING 2021 Page 4 of 4

You might also like