Dayananda Sagar Academy of Technology and Management Department of Computer Science Question Bank

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Object Oriented Concepts – 18CS45 Question Bank

DAYANANDA SAGAR ACADEMY OF TECHNOLOGY AND MANAGEMENT


DEPARTMENT OF COMPUTER SCIENCE
QUESTION BANK
Subject: OBJECT ORIENTED CONCEPTS
Subject Code: 18CS45 [CBCS Scheme]

Subject Code 18CS45 CIE Marks 40


Number of Lecture hours/week 3:0:0 SEE Marks 60
Total Number of Lecture Hours 40 Exam Hours 03
CREDITS – 03
Course objectives: This course will enable students to
• Learn fundamental features of an object oriented language of C++ and JAVA
• Set up Java JDK environment to create, debug and run simple Java programs.
• Create multi-threaded programs and event handling mechanisms.
• Introduce event driven Graphical User Interface (GUI) programming using applets and swings.
Syllabus Teaching CO’s
Hours
MODULE – 1
Introduction to Object Oriented Concepts:
A Review of structures, Procedure–Oriented Programming system, Object Oriented
Programming System, Comparison of Object Oriented Language with C, Console I/O, 8 Hours CO1
variables and reference variables, Function Prototyping, Function Overloading.
Introduction, member functions and data, objects and functions,
Text book 1: Ch 1: 1.1 to 1.9 Ch 2: 2.1 to 2.3

MODULE - 2
Class and Objects: objects and arrays, Namespaces, Nested classes, Constructors,
Destructors. CO1
Introduction to Java: Java’s magic: the Byte code; Java Development Kit (JDK); the
8 Hours
Java Buzzwords, Object-oriented programming; Simple Java programs. Data types,
variables and arrays, Operators, Control Statements.
Text book 1: Ch2: 2.4 to 2.6 Ch 4: 4.1 to 4.2
Text book 2: Ch:1 Ch: 2 Ch:3 Ch:4 Ch:5

MODULE - 3
Classes, Inheritance, Exceptions: Classes: Classes fundamentals; Declaring objects;
Constructors, this keyword, garbage collection. Inheritance: inheritance basics, using
8 Hours
super, creating multi level hierarchy, method overriding. Exception handling: Exception CO1,
handling in Java. CO2
Text book 2: Ch:6 Ch: 8 Ch:10

MODULE - 4
Packages and Interface: Packages, Access Protection, Importing Packages, Interfaces.
Multi Threaded Programming : Multi Threaded Programming, What are threads? How to
make the classes threadable ; Extending threads; Implementing runnable; 8 Hours
Synchronization; Changing state of the thread; Bounded buffer problems, readwrite CO2
problem, producer consumer problems.

Dept Of CSE 2019-2020 1


Object Oriented Concepts – 18CS45 Question Bank
Text book 2: Ch 11: Ch: 9
MODULE - 5
Event Handling: Two event handling mechanisms; The delegation event model; Event
classes; Sources of events; Event listener interfaces; Using the delegation event model;
Adapter classes; Inner classes.
Swings: Swings: The origins of Swing; Two key Swing features; Components and 8 Hours
Containers; The Swing Packages; A simple Swing Application; Create a Swing Applet; CO3,
Jlabel and ImageIcon; JTextField;The Swing Buttons; JTabbedpane; JScrollPane; JList; CO2
JComboBox; JTable.
Text book 2: Ch 22: Ch: 29 Ch: 30

Course Outcomes: The students should be able to:


• Explain the object-oriented concepts and JAVA.
• Develop computer programs to solve real world problems in Java.
• Develop simple GUI interfaces for a computer program to interact with users, and to understand the
event-based GUI handling principles using Applets and swings.

Graduate Attributes
• Programming Knowledge
• Design/Development of Solutions
• Conduct Investigations of Complex Problems
• Life-Long Learning

Question paper pattern:


• The question paper will have ten questions.
• There will be 2 questions from each module.
• Each question will have questions covering all the topics under a module.
• The students will have to answer 5 full questions, selecting one full question from each module.

Text Books:
1. Sourav Sahay, Object Oriented Programming with C++ ,2nd Ed Oxford University Press,2006
2. Herbert Schildt, Java The Complete Reference, 7th Edition, Tata McGraw Hill, 2007.

Reference Book:
1. Mahesh Bhave and Sunil Patekar, "Programming with Java", First Edition, Pearson Education,2008,
ISBN:9788131720806
2. Herbert Schildt, The Complete Reference C++, 4th Edition, Tata McGraw Hill, 2003.
3. Stanley B.Lippmann, Josee Lajore, C++ Primer, 4th Edition, Pearson Education, 2005.
4. Rajkumar Buyya,S Thamarasi selvi, xingchen chu, Object oriented Programming with java, Tata
McGraw Hill education private limited.
5. Richard A Johnson, Introduction to Java Programming and OOAD, CENGAGE Learning.
6. E Balagurusamy, Programming with Java A primer, Tata McGraw Hill companies.

Dept Of CSE 2019-2020 2


Object Oriented Concepts – 18CS45 Question Bank
Module 1
1. Explain the following OOP features:
i) Class ii) Encapsulation iii) Polymorphism iv) Inheritance
(8M) Dec2011, (8M) Jan2013.July2019
2. Explain the various features of object oriented programming. (10M) Jun2010. July2019
3. Discuss the function prototyping, with an example. Also write its advantages.
(5M) Jun2010.
4. State the important features of object oriented programming. Compare the object oriented
system, with procedure oriented system.
(8M) Dec2010, (10M) Dec2014. July2019
5. What is function overloading? Illustrate function overloading through add function which adds
integers and 2 float numbers. (6M) Dec2010, Jun2011.
6. Differentiate between procedure oriented and object oriented programming.
(6M) Jun 2009, (05M) Jan 2018
7. What is data abstraction? How it is implemented in C++. Explain with an example.
(5M) Jun 2009.
8. Discuss the issues of procedure oriented programming system with respect to data security. If
object oriented programming solves it, then how? (8M) Jan 2010.
9. What are the features of reference variable? (4M) Jan2009.
10. Why C++ introduce reference variable? Explain with example. (8M) Jan2009.
11. Give a comparison of C and C++ with an example.
(6M) Jun2011,(10M) Jun2012.
12. What is recursive function? Explain with example. (8M) Jan2014.
13. Different types of argument passing, explain with example. (5M) Jan2011.
14. What is function overloading? Write a c++ program to define 3 overloaded functions area(), to
find area of rectangle , rectangle box and area of circle.
(10M) Dec 2014. July2019
15. Write the general form of function. Explain the different types of argument passing techniques
with an example. (10M) Jun2012/10 Dec 2014.
16. What are nested classes? What is its use? Give an example and explain.
17. What are constructors? When they are called? What is their use? Define a suitable parameterized
constructor with default values for the class TIME with data member hr, min, sec.
(6M) Jun 2009. July2019
18. Explain the term namespace and namespace pollution. (4M) Jan2009.
19. Explain with an example to illustrate the different features of keyword “Namespace” and
“using”. (8M) Jan 009/Dec 2013.
20. Explain the order in which constructors and destructors are involved. (6M) Jun2011.
21. a. How do name space helps in preventing pollution of the global namespace.(4M) July 2017,
(03M) Jan 2018
b. What is function polymorphism? Write a program in C++ using overloaded function area to
find area of circle, triangle and rectangle (6M) July 2017
c. Explain how one can bridge two classes using friend function. Write a C++ program to find the
sum of two numbers using bridge friend function add(). (6M) July 2017
22. a. Can you overload constructor and destructor? Justify with suitable program. (6M) July 2017
b. What is reference variable? Explain. Also write a program in C++ to swap two int values and
Dept Of CSE 2019-2020 3
Object Oriented Concepts – 18CS45 Question Bank
display the values before and after swapping. (5M) July 2017
c. What are static member of a class? Write a C++ program to count the number of objects
created. (5M) July 2017
23. a. Explain function overloading with example (05M) Jan 2018
b. What is constructor? List the different type of constructors and explain default constructor with
example (06M) Jan 2018
24. a. Explain the concept of object oriented program
i) encapsulation ii) Polymorphism iii) Inheritance iv) Data initialization (08 M) Jan 2018
b. Explain function prototyping with example. (05M) Jan 2018
25. What is an inline function? Write a C++ function to find the maximum of 2 numbers using inline.
(08M)July2019

Module 2
1. How ‘compile once and run anywhere’ is implemented in Java, explain.(4M) June 2014, Jan 2013, Jan
2012, (4M) July 2017
2. Define Byte code, How does it help java program (s) achieve portability. (5M) June 2015. July2019
3. Write a java program to sum only the first five elements of the array {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, Using
for-each version of the for loop. (5M) June 2015
4. List and explain the Java buzzwords. (6M) Dec 2015, June 2014, July 2013, Jan 2017, (08M) July
2017 July2019
5. Explain : i) >>> ii) short circuit logical operators iii) for each. (6M) Dec 2015, June 2014, Jan 2017.
6. Describe the process of building and running Java program. (4M) June 2014, Jan 2014, July 2012, Dec
2011.
7. How arrays are defined in java (Explain arrays in java)? with examples. (6M) Jan 2015, July 2013,
Jan 2013, Jan 2017.
8. Defrentiate the usage of acess specifier in java and there scope. (5M) Dec 2015, Jan 2015, Jan 2017.
9. Explain how java is robust and Architecture neutral. (8M) Jan 2014, (5M) June 2015.
10. Write a note on Java Environment. (6M) Jan 2014.
11. Write and demonstrate the java program to initialize and display different types of integers and
floating point variables. (5M) Jan 2015.
12. Define typecasting, explain with example. (5M) Jan 2015.
13. What is jump statement? (4M) July 2013.
14. Discuss break and continue. (5M) Jan 2013.
15. Explain about JDK. (7M) July 2012, Jan 2012.
16. Explain the following: i) JVM ii) Type casting. (8M) Dec 2011.
17. Discuss three OOP principles. (6M) Jan 2014, Jan 2012.
18. class Example {
public static void main (String s[]) {

int a;

for(a=0;a<3;a++){

int b=-1;

Dept Of CSE 2019-2020 4


Object Oriented Concepts – 18CS45 Question Bank
system.out.println(“ “+b);

b=50;

system.out.println(“ “+b);

What is the output of the above code? If you insert another ‘int b’ outside the for loop, what is the
output? (5M) June 2011.

19. With example, explain the working of >> and >>>. (6M) June 2011.
20. What is the default package and default class in Java? (2M) June 2011.
21. Write a program to calculate the average among the elements {4, 5, 7, 8}, using for each in Java. How
for each is different from for loop? (7M) June 2011.
22. Explain the process of compiling and running a java application, with the help of “Hello World”
program. (08M) Jan 2017
23. Explain the syntax of for-each loop. Write a JAVA program to search a key element by using a for-each
loop. (08M) Jan 2017
24. Correct the errors from the following code and explain. (02M) July 2016
byte b =50;

b = b * 2;

25. Write the output of the following code. (02M) July 2016
byte b;
int i = 257;
double d = 323.142;
b = (byte)i;
System.out.println(b);
b = (byte)d;
System.out.println(b);
26. b. Write a program to calculate the average among the elements {8, 6,2, 7} using for each in java. How
for each is different from for loop? (06M) July 2017 July2019
c. Explain type conversion, with an example (06M) July 2017
27. Explain the concepts of arrays and types of arrays in java with examples. Also write a program that
creates and initializes a four integer elements array. Find the sum and average of its values. (08M) July
2017 July2019
28. a. Explain how java is robust and interactive. (05M) Jan 2018
b. Write java program to sum only first five elements of the array using for each looping. (05M) Jan
2018
c. Explain the operation of the following operators with example.
i. % ii >>> iii && (06M) Jan 2018
Dept Of CSE 2019-2020 5
Object Oriented Concepts – 18CS45 Question Bank
29. a. Write java program to initialize and display different types of integers and floating point variables.
(06M) Jan 2018
b. What is type casting? Illustrate with an example. What is meant by automatic type promotion? (06M)
Jan 2018
c. How to declare two dimensional arrays in java? Explain with simple example. (04M) Jan 2018
30. List the different types of operators. Explain any three. (08M)July2019
31. Explain switch case with an example. (06M) July2019

Module 3
1. Describe the significance of final and super, with examples. (6M) June 2014.
2. Explain, with an example each, the effect of keyword “final” with i) a class ii) methods of a class. (5M)
June 2015.
3. What is an exception? Explain the different exception handling mechanisms, with an example. (8M) Dec
2015, June 2014, July 2012, Dec 2011.
4. Why overrien methods are used in java? Example. (8M) July 2013
5. What are command line arguments? WAP to demonstrate. (6M) July 2013
6. What is meant by instance variable hiding? How to overcome it? (4M) Dec 2015, Jan 2013
7. Explain constructor method.how it differs from other member function. (5M) July 2012
8. Write a java program to perform the addition of two complex number by using the method add() by
passing the object as a parameter and display results using method display(). Initialize the real and
imaginary values of the complex number using parameter constructor. (8M) Jan 2015.
9. Write a syntax of try and catch block to handle multiple exception, explain. (4M) Jan 2015.
10. Write short notes on: i) Final class ii) Abstract class. (8M) Dec 2011
11. Difference between method overloading & overriding. (6M) Jan 2014, Jan 2012
12. WAP for stack implementation. (8M) Jan 2014, Jan 2012
13. With example, give two uses of super. (6M) Jan 2014, June 2011
14. Write a program which contains one method which will throw IllegalAccessExeption and use proper
exception handlers so that exception should be printed. (4M) June 2011.
15. What are command line arguments? Write a Java program to read a number as command line arguments
and check whether it is prime or not (04M) Jan 2017
16. What is an exception? Explain the usage of throw keyword with an example. (06 M) Jan2017
17. Distinguish between method overloading and method overriding. (04 M) Jan 2017
18. Create a class figure in JAVA, with the following members dim1, dim2 and abstract method area.
Create subclasses Triangle, Rectangle with implementation of area. (07 M) July 2016
19. Explain dynamic method dispatch with example program (06M) July 2016
20. a. Briefly explain the role of interfaces while implementing multiple inheritance in Java (06M)
July2017
b. Compare and contrast method overloading and method overriding with suitable examples. (06M)
July2017, (05M) Jan2018
c. When constructors are called in the class hierarchy? (04M) July 2017
21. a. With examples, give two uses of super. (05M) July 2017 July2019

Dept Of CSE 2019-2020 6


Object Oriented Concepts – 18CS45 Question Bank
b. Define exception. Write a program which contains one method which will throw
IllegalAcessException and use proper exception handlers so that exception should be printed. (06M)
July2017
c. Define package. What are the steps involved in creating user defined package with an example
(05M) July2017 July2019
22. a. Describe the various levels of access protections available for packages and their implications.
(08M) Jan2018
b. Give the basic form of an exception handling block. (04M) Jan2018 July2019
c. What is the importance of the clause finally? (04M) Jan2018
23. a. Define inheritance. List the different types of inheritance (05M) Jan2018
b. Illustrate with example a super class variable can reference a subclass object. (06M) Jan2018
24. Explain interfaces in java with suitable code. (08M) July2019
25. Write short notes on this keyword with an example. (04M)July2019
26. Explain the java garbage collector. (08M) July2019

Module 4
1. What is synchronization? Explain with an example, how synchronization is implemented in Java. (6-
10M) Jan 2014, June 2014, Jan 2013, Jan 2012, June 2011.
2. Why is the “main” thread important? Write a java program that creates multiple child threads and also
ensures that the main thread is the last to stop. (10M) June 2015
3. What is the need for synchronization? How can synchronization be achieved in java? (5M) June 2015,
Jan 2017.
4. What is synchronization? What is producer – consumer problem? Explain the solution for producer –
consumer problem with a program. (10M) Dec 2015, Jan 2015, June 2014, Dec 2011.
5. What is meant by multithreaded programming? Explain with an example inter-thread communication.
(10M) July 2013, Jan 2013, Dec 2011.
6. What is meant by thread priority? How to assign and get the priority. (6M) Jan 2015, July 2013.
7. Explain action event class & adjustment event class. (4M) Jan 2013.
8. Short notes on static, Final, Abstract, Native. (10M) July 2012
9. What is a package? What are steps involved. (10M) July 2012
10. What is a thread ? explain 2 ways of creating thread. (10M) Dec 2015, Jan 2014, Jan 2012, Jan 2017,
July 2016, (05M) Jan 2018 July2019
11. With syntax, explain use of isAlive() and join() methods. (4M) June 2011, (06M) July 2017 July2019
12. Enlist the different methods in WindowListener. What is the use of WindowAdaptor? (3M) June 2011.
13. Write a java program to create two threads, one displays “computer science” and another displays
“information science” five times. (08M) July 2016
14. Write a java program to find a factorial of N numbers recursively. (04M) July 2016
15. a. How synchronization can be achieved for threads in Java? Explain with syntax (06M) July 2017
b. Explain the adapter class with an example. (04M) July 2017
16. a. What are the differences between suspending and stopping the threads (05M) July 2017
17. a. What is synchronization? When do we use it? (05M) Jan 2018
18. Explain the role of synchronization with producer and consumer problem. (08M) Jan 2018

Dept Of CSE 2019-2020 7


Object Oriented Concepts – 18CS45 Question Bank

Module 5
1. Explain the mechanism of event delegation model. Give an example for using keyboard event and
mouse event. Dec 2015, Jan 2015, Dec 2011.
2. Write short notes on Event Listener interface and explain any 2 interfaces with syntax (08M)
July2019
3. Discuss delegation event model with suitable examples. (06M) July 2017, (08M) Jan 2018
4. Explain inner class with example (05M) July 2017 July2019
5. Explain keyEvents and mouseEvent class. (06M) Jan 2018 July2019
6. Explain any two event listener interfaces with its function or methods. (5M) Jan 2015, Jan 2015.
7. What is delegation event model? Describe the significance of adapter class, with an example. (6M) June
2014, July 2013, Jan 2017.
8. Write a swing applet program to demonstrate withtwo Jbuttons named India and Srilanka. When either
of buttons pressed, it should display respective label with its icon. Refer the image icons "India.gif"and
"Srilanka.gif". Set the initial label is "press the button". (10M) Jan 2015.
9. Explain the JScrollPane with example. (5M) Jan 2015.
10. Explain the IComboBox with example. (5M) Jan 2015.
11. What is swing? List the main swing features. Explain the different types of panes of swing containers.
(6M) Jan 2014, June 2014, July 2013, Jan 2013, July 2012, July 2016.
12. Create a swing application having two buttons named alpha and beta. When either of the buttons
pressed, it should display “alpha pressed” and “beta pressed” respectively. (6M) Dec 2015, June 2014.
13. List the different types of swing buttons. Write a program to create four types of buttons on JApplet. Use
suitable events to show actions on the buttons and use JLabel to display the action invoked. (8M) June
2014, Jan 2012, Jan 2017.
14. Write the steps to create Jtable. WAP to create a table with the column headings Name, USN, age,
address & insert records and display. (10M) July 2013, Jan 2017,(05M) July 2017
15. Difference between swings and AWT. (5M) Jan 2013.
16. What is a swing? Explain the components and containers in the swings. (10M) Dec 2011, July 2016.
17. How AWT is different from Swings? What are the two key features of it? Explain. (8)June 2015, June
2011.
18. List 4 types of buttons in swings with their use and syntax. Dec 2015, Write a program to create 4
different types of button on JApplet. Use suitable events to show actions on the buttons and use JLabel
to display the action invoked. (12M) June 2011.
19. Explain with Syntax:
i) JLabel
ii) JText Field
iii) JButton
iv) JCheckBox
v) JList
vi) JTable (12)June 2015, July 2016. (08M) Jan 2018 July2019
20. Explain the following, with an example for each:
i) J Text Field class ii) J Button class iii) J Combo Box class. (10M) Dec 2011.
21. a. Explain briefly the components and containers used in swings. (05M) July 2017
Dept Of CSE 2019-2020 8
Object Oriented Concepts – 18CS45 Question Bank
b. Explain JLabel and ImageIcon with program. (06M) July 2017
22. a.Create swing applet that has two buttons named bet and gamma. When either of the buttons pressed, it
should display ”beta pressed” and “gamma was pressed” respectively. (08M) Jan 2018
b. Explain getDocumentbase and getCodebase in applet class. (08M) Jan 2018

Dept Of CSE 2019-2020 9

You might also like