2006 Anna University B.
E Information Technology
IF 144 — OBJECT ORIENTED PROGRAMMING
PART A — (10 ´ 2 = 20 marks)
1. How is data hiding implemented in C++?
2. Compare overloading and overriding of functions.
3. What are the functions of new and delete operators?
4. What is the need for friend functions?
5. Why do we need virtual functions?
6. How do you overload a postfix and a prefix increment operator?
7. When do we declare a coust member function?
8. What are the properties of a static class member?
9. What does system out represent in Java? How is it used?
10. What is an abstract method in Java?
PART B — (5 ´ 16 = 80 marks)
11. What are the basic principles of Object Oriented Programming? Explain with examples, how they are
implemented in C++?
12. (a) Create a class vector to represent an one dimensional vector with addition operator + to represent and a
scalar product operator to represent . Use them in a main program.
Or
(b) Can the insertion operator << and the extraction operator >> be members of a class? Give examples to
justify your answer.
13. (a) What are the different kinds of inheritance? Explain them with suitable examples.
Or
(b) Define a class Cartesian to represent a point in Cartesian co-ordinates and class polar to represent it in
polar co-ordinates . Use constructor conversion and operator conversion functions in class Cartesian to
convert object of one type into another. Use them in a main program.
14. (a) Write a Java program to illustrate the difference between an instance variable and a class variable.
Or
(b) Write a Java program that creates a Date class and use it with appropriate members and methods.
15. (a) Write a Java applet that asks the user to enter two floating point numbers, obtain the two numbers from
the user and draws the sum and product of the two numbers.
Or
(b) Define a Java method to find the greatest among three numbers. Write a Java applet that obtains three
numbers from the user and displays the largest using the method.
2006 Anna University B.E Computer Science
CS237-OBJECT ORIENTED PROGRAMMING -2
PART A
1.What is meant by data hiding.
2.Name atleast two OOPS languages other than C++.
3.How is “This pointer”useful in programming?
4.What is meant access specifier?
5.What is friend function?
6.Name the various types of multiple inheritance.
7.Is template a basic feature of C++.Justify your answer.
8.What are the classes in iostream.h header files?
9.Does Java support multiple inheritance justify your answer.
10.What is abstact class in Java?
PART B
11 (i) What is the main draw-back of structured programming? How OOP address this issue?
(ii) What are the elements of OOPS? How do these make OOPS approach best suited to address real world
problems?
(iii)Briefly explain the Java runtime environment.
12(a) Explain copy constructor.
Write a program which reads a complex number and copy that into another. Use copy constructor for writing
program.
(b) (i) What is the difference between register variable and automatic
Variable explain with example? What are other stroage classes for variables?
(ii)What is inline funtions? Explain with example.
What is the output of the following segment.
Void f1()
{
Int n=1;
n++;
cout<<”N:”<<N<<ENDL;
void f2()
{
Static int m=1;
M++;
Cout<<”m:”<<M<<ENDL;
#include
#include
Void main()
{
void f1();
void f2();
f1();
f2();f2();
f2();
getch();
}
13 (a) (i) Write a program which reads the bio-data and records of two
Sessional and then print final result. Make seperate class for bio-data,sessional 1, sessional 2 and final result.
Sessional 1 and sessional 2 classes are derived form bio-data class. Find result in defined from sessional 1 and
sessional 2 classes.
(ii) Explain the concepts identify in the program.
(b) (i) What is meant by overloading? How is operator overloading works?
(ii) Write a program to add 2 complex numbers using operator overloading. What are the operators that cannot
be overloaded in C++?
14 (a) (i) Write a program which generate a template class by which one can perform integer type data
addition and float type data additio also.
(ii) What is the need for and advantages of templates? What is the difference between function templates and
class template?
(b) (i) What is exception handling? Explain
(ii) For handling exception what type of construct are available in C++.
(iii) Explain the concept of streams in C++ and give the hierarchy of different types of stream.
15 (a) Defines interfaces in Java. How interfaces are implemented? How they can be accessed? How to apply
interfaces? What is meant by extension of interfaces? Explain with an example.
(b) (i) How is object class created in Java environment? Discuss on objects in Java.
(ii) What is meant by overloading objects? How are rested classes used in Java?
2006 Anna University B.E Computer Science
CS 237 — OBJECT ORIENTED PROGRAMMING
PART A — (10 ´ 2 = 20 marks)
1. How are data and functions organised in an object oriented programming?
2. Compare function overloading and default arguments.
3. What are the uses of references in functions?
4. What is dynamic binding?
5. Compare private and public access specifiers in a class.
6. Distinguish between overloaded functions and function templates.
7. What is this pointer? How is it available to member functions of a class?
8. Can the parameter of a copy constructor be passed by value? Justify your answer.
9. Compare constructor conversion and operator conversion.
10. What is the difference between system . out . print and system . out . println in Java?
PART B — (5 ´ 16 = 80 marks)
11. Explain in detail the following principles of object oriented programming
(i) Data encapsulation and data hiding
(ii) Inheritance and polymorphism
(iii) Generic programming.
12. (a) Create a class complex to represent complex number with overloaded addition and multiplication
operators. Use them in a main program.
Or
(b) Define a class string with appropriate constructors, destructor and overloaded +, =, and = = operators use
them in a main driver program.
13. (a) What are the different forms of inheritance? Give example for them.
Or
(b) Create an abstract base class shape with two members base and height, a member function for
initialization and a pure virtual function to compute area ( ). Derive two specific classes Triangle and
Rectangle which override the function area ( ). Use these classes in a main function and display the area of a
triangle and a rectangle.
14. (a) Write a C++ program containing a possible exception. Use a try block to throw it and a catch block to
handle it properly.
Or
(b) Create a data class using Java with the following capabilities.
Out the date in multiple format such as
(i) dd – mm – yy
(ii) June 14, 2002.
15. (a) Write a Java class point to represent a two dimensional point (x, y). Extend it to a class circle with its
centre as the point and an additional radius member and extend further to a class cylinder with additional
height member.
Or
(b) Explain the concept of nested classes in Java with a suitable example.
2006 Anna University B.E Computer Science
CS1204 – OBJECT ORIENTED PROGRAMMING
PART A – (10 ´ 2 = 20 marks)
1. Name the mechanism that binds together code and the data it manipulates.
2. What is the application of the scope resolution operator: in C++?
3. What are the two parts of a class specification?
4. What is an operator function? Describe the syntax of an operator function.
5. Why is it necessary to include the file iostream in all our programs?
6. Name the two ways in which a file can be opened.
7. What is default for methods in Java?
8. What is the need for Java virtual machine?
9. What is a package?
10. What is an exception?
PART B – (5 ´ 16 = 80 marks)
11. (a) Explain the following concepts of object oriented programming:
(i) Data abstraction
(ii) Inheritance
(iii) Polymorphism and
(iv) Objects
In detail with an example. (16)
(b) (i) List out any five merits of object oriented methodology.
(ii) Compare and contrast the following control structures with example.
If ….else statement and switch statement and do ….. while and the while statement.
12. (a) Write a program to overload = operator. Assign values of data members of one object to another object
of the same type.
Or
(b) Write a C++ program using inheritance to implement the following.
A newspaper agent pays two variant rates for the delivery of newspapers. Adelivery boy can earn RS. 2 on a
morning delivery but only Rs. 1.50 on an eveningdelivery. Boys are salaried either for a morning delivery or
for an evening paper round
but not for both. Read(Input) the code for round (0 for morning and 1 for evening) and
the number of total paper rounds in one week done by a boy and compute his earning and display it.
13. (a) Write a program to write and read data in a file using object I/O functions write ( ) and read ( ).
Declare class with data members name [2] m int bill no, int _amount
debited and int received _ amount and in balance. Add 10 records and display the list of persons with
balances. The user should have a facility to modify the existing records.(16)
Or
(b) (i) Describe the various file modes and its syntax. (6)
(ii) Discuss the need for exception with try, catch and throw keywords. (10)
14. (a) Write short notes on the following:
Final class, abstract class, modifier final, inner classes.
Or
(b) (i) State the rules for creating an identifier in Java.
(ii) Discuss about the reference variable array and the primitive data types byte,
long, double. (10)
15. (a) Discuss how interface is implemented in Java with an example. (16)
Or
(b) What is a thread? State how synchronization is dealt while using multithreading.
(16)
2006 Anna University B.E Electrical and Electronics
OBJECT ORIENTED PROGRAMMING
PART A (10*2=20MARKS)
1.What are the features provided by object based and object oriented languages?
2.What type of abstraction is employed in (a) procedure (b) Object Oriented Programming?
3.Model a mobile phone as a class.
4.Write a function to swap two integer values using reference variables.
5.What are the operators of C++ that cannot be overloaded?
6.Indicate how different types of members of base class are visible in (a) Public and (b) Private derivation.
7.Describe the following function's declaration
virtual void service (int n) = 0;
8.Can you have a class named main in C++? If yes, how do you call its constructor?
9.What is the main purpose of a template in C++? Give an example.
10.Which of the following statements are correct?
int const *pi = & x;
(a) x=10;
(b) *pi=10;
(c) pi ++;
(d) ++*pi;
PART B-(5*16=80 MARKS)
11. (i) Model a delta network (with resistors) as a class.Equip the class with required data and function
members. Write a program to test the class and to display te equivalent delta network.(8 marks)
(ii) Simulate a simple electrical system using C++ program. Describe identification of classes and objects.
Write a test program to illustrate the design. (8 marks)
12. (a) Explain the following characteristics of object oriented programming with examples.
(i) Data Encapsulation
(ii) Polymorphism
(iii) Genericity
(iv)Inheritance. (4*4=16 marks)
OR
(b) (i) Is there a difference between List x and List x ()? Explain. (6 marks)
(ii) How do member functions, friend functions and non member functions differ? Give a programming
example to support your answer. (10 marks)
13 (a) (i) What are the different ways of writing default constructors? Give examples. (8 marks)
(ii) What is a dangling pointer? Give an example. (8 marks)
OR
(b) (i) What are the default arguments? Give an example to illustrate programming syntax. (8 marks)
(ii) Write a C++ program to print the following triangle of numbers.Keep your program as short as
possible.Read n as input. (8 marks)
1
22
333
4444
14 (a) Assume the following is allowed
Complex c1 (5,4), c2 (-5,4);
c1++; ++c2;
c2=c1 + c2;
c1 +=c2;
c1= -c1;
cout<< c1;
Write a C++ program to perform these operations. (16 marks)
OR
(b) Give an application that fits the following inheritance hierarchy and write the program for the same. Each
class should have atleast two data members and two function members.
(16 marks)
15. (a) (i) Explain the need for a virtual destructor? (8 marks)
(ii) Describe dynamic binding and how is it implemented in C++? (8 marks)
OR
(b) (i) Consider the following program segment:
class A {
public :
A (void) {cout << "How";}
~A (void) {cout << "What";}
};
class B : A {
public :
B (void) {cout << "Why";}
~B (void) {cout << "Hello";}
};
What does the declaration B x print? If the main function has the following two statements, what will be the
output?
B x; cout << "Done" (6 marks)
(ii) Give the syntax of fuction template. Write a template function for sorting. Write a test program to
illustrate its use. (10 marks)