OBJECT ORIENTED PROGRAMMING (CSEN 3103)
OBJECT ORIENTED PROGRAMMING (CSEN 3103)
Group – A
(Multiple Choice Type Questions)
CSEN 3103 1
B.TECH/CSE/5TH SEM/CSEN 3103/2021
(a) 6 (b) run time error
(c) Compilation error (d) 10.
(iv) Dynamic method dispatch is important because this is how Java implements -
(a) Garbage Collection (b) Run time Polymorphism
(c) Exception Handling (d) Encapsulation.
(v) “Writing destructor of a class is mandatory (Default destructor is not enough)”.
The above statement is -
(a) always true
(b) always false
(c) when class has pointers as an instance variable
(d) none of the mentioned.
(vi) Which of the following cannot be instantiated?
(a) Abstract Class (b) Concrete class
(c) Interface (d) Exception class.
Group – B
2. (a) What is the difference between static binding and dynamic binding?
[(CO1)(Understand/LOCQ)]
(b) Discuss the programming construct(s) via which C++ implements static binding
and dynamic binding. [(CO5)( Analyze/LOCQ)]
(c) Explain with example the difference between deep copy and shallow copy and in
which situation use of deep copy is essential. [(CO2)(Understand/IOCQ)]
4 + 4 + 4 = 12
CSEN 3103 2
B.TECH/CSE/5TH SEM/CSEN 3103/2021
cout << *((int *)ptr)<<endl;
}
The pointer ptr given in the above program has a special name and use. What is
the name of that pointer and explain its uses with example. Write necessary
code to reassign ptr to point to a character array and print it's content.
[(CO5)(Analyze/IOCQ)]
(b) class test {
int var;
public:
test() { var=0; }
test(int a=5) { var=a; }
};
int main() { test obj(); }
What is going to happen when you compile the above program? Explain why.
[(CO6)(Analyze /HOCQ)]
(c) Rewrite the above program, with minimal code change, so that it compiles
without any error. [(CO6)(Analyse/HOCQ)]
(3 + 3) + (1 + 2) + 3 = 12
Group – C
4. (a) Write two advantage and two disadvantage of Inheritance.
[CO1(Analyze/IOCQ)]
(b) Can you call a parameterized constructor of a base class while creating the
object of child class? If yes, write the syntax. If no default constructor for base
class is available and you are not using any parameterized constructor of base
class while creating the child class, what will happen while creating derive
object? [CO1,CO5,CO6(Evaluate/HOCQ)]
(c) In class Animal you have defined two constructors
Animal(int x) { } and Animal() {}
You have defined following classes :
class Lion : virtual public Animal {
public :
Lion(int x): Animal(x) { }
};
class Tiger : virtual public Animal {
public :
Tiger(int x): Animal(x) { }
};
class Liger : public Tiger, public Lion {
public:
Liger(int x): Lion(x), Tiger(x) { }
};
Now create the Liger object in main
int main() { Liger lg1(30); }
How many times the Animal constructor will be called when lg1 is created and
why?
CSEN 3103 3
B.TECH/CSE/5TH SEM/CSEN 3103/2021
Write sequence of constructor calling indicating the type of constructor when
lg1 is created in main(). In above scenario base Animal’s default constructor is
called although Animal(x) is specified in Lion and Tiger. What change is needed
to call Animal’s parameterized constructor? [CO5,CO6(Evaluate/HOCQ)]
3 + 3 + 6 = 12
Group – D
6. (a) Explain how bytecode helps java programs to become platform independent.
[(CO1)(Understand/LOCQ)]
(b) Write a program in Java that takes 5 integers as command line arguments, sorts
them and prints the result. [(CO5) (Analyse /IOCQ)]
(c) Public class complex {
complex() {System.out.println("In constructor");}
}
public class test {
public static void main(String args[]) {
complex obj=new complex();
}
The above program will give a compilation error.
Point out the error. Explain the reason behind the error. Fix it.
[(CO6)(Analyse/HOCQ)]
2 + 5 + (2 + 2 + 1) = 12
7. (a) State whether each of the following is true or false. If a statement is false,
explain why.
(i) Superclass constructors are not inherited by subclasses.
(ii) A ‘has-a’ relationship is implemented via inheritance.
(iii) A Car class has an ‘is-a’ relationship with the SteeringWheel and Brakes
classes.
(iv) When a subclass redefines a superclass method by using the same
signature, the subclass is said to overload that superclass method.
[(CO1)(Analyze/IOCQ)]
(b) Explain the difference between method overriding and method overloading
with the help of suitable example in Java. [(CO1)(Remember/LOCQ)]
(c) What is the use of the finalize() method in Java? When is a finally block
executed? [(CO5)(Remember/LOCQ)]
CSEN 3103 4
B.TECH/CSE/5TH SEM/CSEN 3103/2021
class FinalVariable1 {
public static void main(String args[]) {
final int i = 30; i = 60;
}
}
What is wrong in the above code? [(CO6)(Understand/HOCQ)]
4 + 5 + (2 + 1) = 12
Group – E
8. (a) Differentiate between checked and unchecked exceptions in java.
[(CO5)(Remember/LOCQ)]
(b) Explain with example the difference between throw and throws in Java.
[(CO3)(Analyse/IOCQ)]
(c) Define the terms abstract classes and interfaces in Java. Give an example to
show why interfaces are preferred over abstract classes.
[(CO1)(Remember/IOCQ)]
4 + 4 + 4 = 12
9. (a) What are the scenarios in which a method in an interface can have a method
body? Explain with examples. [(CO1)(Remember/LOCQ)]
(b) What are the two ways you can use to create a thread in java? If you had to
choose one way (of creating thread) over another which one would you choose
and why? [(CO4)(Understand/LOCQ)]
(c) What is thread synchronization and why is it needed? [(CO4) (Analyse/HOCQ)]
4 + (2 + 2) + 4 = 12
_________________________________________________________________________________________________________
CSEN 3103 5
B.TECH/CSE/5TH SEM/CSEN 3103/2021
Department &
Submission Link
Section
CSE A https://classroom.google.com/c/NDA0MjM4MzcyMTk5/a/NDY0MTY0NjYzNzA5/details
CSE B https://classroom.google.com/c/NDA1MzE0MjkxNzcz/a/NDYzODg2NDM1NTk1/details
CSE C https://classroom.google.com/c/NDA1MTY0MDkzMTk1/a/NDYzOTAyMzQwNjcy/details
CSEN 3103 6