You are on page 1of 9

MAY/JUNE 2006 Third Semester COMPUTER SCIENCE AND ENGINEERING CS1204 - OBJECT ORIENTED PROGRAMMING

PART A 1. What is object oriented programming? How is it different from the procedure oriented programming? Object Oriented programming is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used us templates for creating copies of such modules on demand. Object oriented programming is suitable for the description of abstraction objects. But it is not suitable for procedure oriented programming.

2. How does an inline function differ from a preprocessor macro? A preprocessor macro consist of their function body before the complation. But inline function have explicit function.

3. How do we declare a member of class static? Class classname { ------Static DataType Datamember; ---}; Datatype ClassName::DataMember=InitialValue; 4. Can friendship between classes be symmetric or transitive? Justify your answer with an example?

It provide transitive. It can be either declared in the private part or the public part of the class without affecting meaning. 5. Explain the various file stream classes needed for manipulator? Ifstreamhandling Input Ofstream handling Output Fstream handling Input & Output 6. What are file pointers? Describe get-pointers an put-pointers. The file management system associates file pointers with each file, called file pointers. The get-pointer specifies a location from where the current reading operation is initiated. The put pointer specifies a location from where the current writing operation is initiated. 7. Define Java Virtual Machine? Java enables the creation of cross-plot forme programs by compiling the code into an intermediate representation called Java byte code. This code can be interpreted on any system that has a Java virtual machine. 8. What is the major difference between interface and a class?

Interface The interface should not contain implementation for its method An interface, which is implemented with in class

Class It contains implementation for its method.

Classed are able to access methods of an

9. What is a package? Packages are containers for classes that are used to compartmentalize the class name space. Packages are stored in a hierarchical manner and are explicitly imported into new class definitions. 10. What are the two methods by which we may stop threads? Athread.stop(); it moves to dead state Sleet(); blocked for specified time.

PART - B 11.(i) What is Copy constructor?Explain it with suitable C++ coding? Syntax: Classname(classname & object-ref) Program: #include<iostream.H> #include<conio.h> class complex { int r,i; public:complex(int a,int b) { r=a; i=b; } complex(complex c) { r=c.r; r=c.i; } void show() { cout<<r<<+I<<i<<endl; } void main() { int x,y; clrscr(); cout<<Enter real part; cin>>x;

cout<<enter imag part; cin>>y; complex c1(x,y); compelx c2(c1); cout<<1st no is; c1.show(); cout<<second no. is; c2.show(); getch(); }

(ii) Write a program to overload the assignment operator using C++ language. Program: #include<iostream.h> #include<conio.h> class sample { int d; public:sample c1 { d=0; } sample(int a) { d=a; } void operator=(sample s1) { d=s1.d; } void operator +=(sample s2)

{ d=d+s1.d; } }; void main() { sample s3; sample s4(6); sample s5(7); clrscr(); s3=s4; s5+=s4; cout<<Data member of s3 is<<endl; s3.show(); cout<<s4; s4.show(); cout<<s5; s5.show(); getch(); }

12.(a)(i) Explain the elements of object oriented programming? Object & class Encapsulation Abstraction Inheritance Polymorphism Object oriented programming Language

(ii) What are the differences between reference variable and normal variables? Why cannot a constant value be initialized to variables of reference type?

(b)(i) What are the differences between pointers to constants and constant pointers? Give example?

(ii) What are the advantages of using pointers in programming? Explain addressing mode required to access memory location using pointers.

13.(a)(i)Write a program which copies the contents of one file to a new file by removing unnecessary spaces between words.

(ii) Write a program to print the ASCII table using streams. 13(b)(i) What is the difference between the statements? Cin>>ch; Ch=c in.get();

(ii) Write a program to overload the insertion and deletion operators in c++.

14(a)(i) Give an example that fits the following inheritance hierarchy. A

Write a Java program to implement the example

14(b) Write statements that performs the following single-subscribed array operations: set the 10 elements of integer array counts to zeros. Add 1 to each of the 15 elements of integer array bonus Print the five values of integer array best scores in column format.

15(a)(i) Explain Multithreading with suitable java code . (ii) Write a program that accepts a name list of five students from the command line and store them in a vector.

(b) What is the purpose of using packages? How do you create user-defined package? Give an example.

You might also like