[go: up one dir, main page]

0% found this document useful (0 votes)
20 views6 pages

OBJECT ORIENTED PROGRAMMING (CSEN 3103)

The document outlines the examination structure for the Object Oriented Programming course (CSEN 3103) for B.Tech CSE 5th semester students, including multiple choice questions and detailed problem-solving questions across various groups. It emphasizes the importance of understanding object-oriented principles, error management, multithreading, and the comparative merits of C++ and Java. Additionally, it provides links for submission and details about cognitive levels of questions.
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)
20 views6 pages

OBJECT ORIENTED PROGRAMMING (CSEN 3103)

The document outlines the examination structure for the Object Oriented Programming course (CSEN 3103) for B.Tech CSE 5th semester students, including multiple choice questions and detailed problem-solving questions across various groups. It emphasizes the importance of understanding object-oriented principles, error management, multithreading, and the comparative merits of C++ and Java. Additionally, it provides links for submission and details about cognitive levels of questions.
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/ 6

B.

TECH/CSE/5TH SEM/CSEN 3103/2021


B.TECH/CSE/5TH SEM/CSEN 3103/2021

OBJECT ORIENTED PROGRAMMING


(CSEN 3103)

Time Allotted : 3 hrs Full Marks : 70


Figures out of the right margin indicate full marks.
Candidates are required to answer Group A and
any 5 (five) from Group B to E, taking at least one from each group.
Candidates are required to give answer in their own words as far as practicable.

Group – A
(Multiple Choice Type Questions)

1. Choose the correct alternative for the following: 10 × 1 = 10


(i) A function’s single most important role is to
(a) give a name to a block of code
(b) increase program size
(c) accept arguments and provide a return value
(d) help organize a program into conceptual units.
(ii) Copy constructors are called when -
(a) We create one object from another of the same type.
(b) Copy an object to pass it by value as an argument to a function
(c) Copy an object to return it from a function.
(d) All of the above.
(iii) What is the output of the following program?
public class Outer
{
public static int temp1 = 1; private int temp2 = 4;
public static class Inner
{
private static int temp3 = 5;
private static int getSum() {
return (temp1 + temp2 + temp3);
}
}
public static void main(String[] args)
{
Outer.Inner obj = new Outer.Inner();
System.out.println(obj.getSum());
}
}

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.

(vii) Which of the following operator cannot be overloaded?


(a) ++ (b) [] (c) :: (d) new
(viii) A static local variable in a function is used to
(a) make a variable visible to several functions
(b) retain a value when a function is out of scope
(c) make a variable visible to only one function
(d) (b) and (c)
(ix) Which one is not a Thread class method?
(a) join() (b) paint() (c) start() (d) run()
(x) A template class
(a) is designed to be stored in different containers
(b) generates objects which must be identical
(c) works with different data types
(d) generates classes with different numbers of member functions.

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

3. (a) int main () {


void *ptr; int x=6; ptr=&x;

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

5. (a) What is a function template? [(CO5)(Remember/LOCQ)]


(b) Function 'add' takes 2 parameters and returns the sum. However, the data type
of the two numbers can vary. Write a program to implement the scenario using
function template. [(CO5)(Analyze/IOCQ)]
(c) Explain the different uses of the throw keyword in C++. [(CO3)(Analyze/IOCQ)]
(d) What is the difference between method overloading and method
overriding? [(CO1)(Analyze/IOCQ)]
2 + 3 + 4 + 3 = 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
_________________________________________________________________________________________________________

Cognition Level LOCQ IOCQ HOCQ


Percentage distribution 32.3% 41.7% 26%
Course Outcome (CO):
After the completion of the course students will be able to
CSEN3103.1. Understand the principles of object-oriented programming.
CSEN3103.2. Compare the relative merits of C++ and Java as object-oriented programming
languages.
CSEN3103.3. Understand the importance of error management and incorporate exception-
handling in object-oriented programs.
CSEN3103.4. Apply multithreading techniques to improve performance.
CSEN3103.5. Apply the features of C++ and Java supporting object-oriented programming to
develop modular applications.
CSEN3103.6. Analyze problems and estimate when object-oriented programming is an
appropriate methodology to design and develop object-oriented software
using C++ and Java.
*LOCQ: Lower Order Cognitive Question; IOCQ: Intermediate Order Cognitive Question;
HOCQ: Higher Order Cognitive Question

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

You might also like