CS1204 06JUN.pdf
-
Upload
thangamkarna -
Category
Documents
-
view
213 -
download
0
Transcript of CS1204 06JUN.pdf
-
7/28/2019 CS1204 06JUN.pdf
1/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 procedureoriented 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 withan example?
-
7/28/2019 CS1204 06JUN.pdf
2/9
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 Class
The interface should notcontain implementation for its
method
It contains implementation forits method.
An interface, which is
implemented with in class
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.
-
7/28/2019 CS1204 06JUN.pdf
3/9
PART - B
11.(i) What is Copy constructor?Explain it with suitable C++ coding?
Syntax:
Classname(classname & object-ref)
Program:
#include
#include
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
-
7/28/2019 CS1204 06JUN.pdf
4/9
couty;
complex c1(x,y);
compelx c2(c1);
cout
-
7/28/2019 CS1204 06JUN.pdf
5/9
{
d=d+s1.d;
}
};
void main()
{
sample s3;
sample s4(6);
sample s5(7);
clrscr();
s3=s4;
s5+=s4;
cout
-
7/28/2019 CS1204 06JUN.pdf
6/9
(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.
-
7/28/2019 CS1204 06JUN.pdf
7/9
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++.
-
7/28/2019 CS1204 06JUN.pdf
8/9
14(a)(i) Give an example that fits the following inheritance hierarchy.
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.
A
B
C
Write a Java program to implement theexample
-
7/28/2019 CS1204 06JUN.pdf
9/9
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.