Prof. Ramkrishna More Arts, Commerce & Science College S.Y.B.Sc.(Computer Science) Subject Object oriented concepts & programming in C++. Theory Assignments-1 Q.1) Answer the following.(1m) 1. List any 2 languages other than C++,which support object oriented programming concepts. 2. What do you mean by late binding. 3. State any one advantages of object oriented programming over procedure oriented programming. 4. Explain the following a)polymorphism (b) Date Encapsulation. Theory Assignments-2 1. Explain any two access specifiers. 2. Why you need a scope resolution operator to access global variable? 3. What are manipulators?explain any two manipulators with example. 4. C++ is a pure object oriented Language, justify true or false. 5. Which bit must be turned on to print member along with + sign. 6. Why do reference variable have to be initialized? 7. State syntax to create a reference variable. 8. Write the C++ statement to free the memory allocated by following statement. int *p=new int(10); 9. List any 2 features of C++ programming language. 10. Give the syntax for explicit type conversion of a variable or expression in C++. 11. Explain any two predefine manipulators. 1. Write a macro in C++ to find the maximum of 2 positive integers. 2. What is memory management operator?explain the operator new with example. 3. Give any two advantages of new over malloc. 4. Write menu driven program in C++ to calculate the area of circle and rectangle. 5. Write a program to input a single character through keyboard & print its ASCII value and Hexadecimal value. 6. Trace the output of the following. Class sample Private:Static int cnt; Public: sample()++cnt; Void display()cout<< cnt= <<cnt; Int sample::cnt=0; Void main() sample S1,S2,S3,S4; S4,display();
Theory Assignments-3 1. Explain array of object. 2. How does class declaration differ from class definition? 3. Write C++ statement to allocate memory dynamically for an array of 10 points to object of some class,say A. 4. Why can t initialize members within class. 5. How does class achieve data hiding? 6. What are objects?how are they created? 7. Class members are public by default.justify(t/f). Theory Assignments-4 1. List the functions of istream class. 2. What will be the output of the following C++ statement. Cout.precision(2); Cout.width(6); Cout<<7.1234; 1. Explain C++ stream classes. 2. What is a manipulator?write manipulator called currency which display Rs. when output is called. Theory Assignments-5 1. Justify true/false. a) In procedure oriented programming all data items are shared by all functions. b)function can not return class object. 2. Give two methods,which are,used it defined member function. 3. What is inline function? 4. What is function overloading? 5. What is difference between inline function & normal function? 6. What are disadvantages of inline function? 7. Why can t static member function access non-static member class? 8. State the reason why we cannot use the this pointer in a friend function. 9. A function can return value by references.comment. 10. Give the syntax to create reference variable. 11. Explain friend function with example. 1. What is function overloading? Explain with example. 2. Explain static data member and static member functions with the help of suitable example. 3. What is inline function? how does it differ from regular function? State one advantages & disadvantage of using inline function. 4. Explain call by reference and return by reference with example. 5. What is friend function? What are advantages & disadvantages of friend function.
6. Write a program to find GCD of two positive integer using function. Theory Assignments-6 1. Justify true/false :destructor takes input parameter. 2. What is constructor? Is it mandatory to use destructor in class? 3. How many time will constructor of class student be invoked for the following statement. Student s,*p; 4. Find the error in following code. class NUMBER int a; void NUMBER(int x=0) a=x; 1. Define a constructor. Explain the copy constructor & parameterize constructor with example. 2. Trace the output of following program : a) Class Wilma public: Wilma() cout<< Wilma cnt\n ; Void f() cout<< Wilma used\n ; Class Fred public: Fread() cout<< Fred cnt\n ; Protected : Static Wilma Wilma_; Fred f; Wilma Fred::Wilma_; Main() b) class A public : A()cout<< Cnt\n ; ~A()cout<< Dstr\n ; A a1,a2; main() A a3,a4,a5; int i=0; if(i) A a6; else exit(1); A a7;
c) class X public: X() cout<< default cnt\n ; X(const X&) cout<< copy constructor\n ; X UserCode(X b) X c=b; return c; main() X a; cout<< calling user code()\n ; X d=usercode(a); cout<< Back in main()\n ; d) class Table Public: Table() cout<< cnt \n ; ~Table() Cout<< Dstr\n ; Table t1; Table t2=t2; Table t3; main() t3=t2; Theory Assignments-7 1. List the operator which cannot be overloaded.
2. If unary operator is overloaded as a member function,how many implicit & explicit arguments does it require? 3. Which operator must be overloaded as member (not friend )function? 4. Write the syntax for overloading << operator. 1. Explain this pointer with suitable example. 2. What is polymorphism?how polymorphism is achieve in C++?Explain any one polymorphism with suitable example. 3. Write a program in C++ using operator overloading to print n terms of fibonacci series. 4. Define class string.use overloaded operator == to compare two strings. 5. Write program to multiply two matrices.let m1 and m2 are two matrices.find out m3=m1*m2(use operator overloading). 6. Define a class matrix with necessary members. Overload operator + as friend function to add 2 matrices. Also write main() to test this function. Theory Assignments-8 1. List the types of inheritance. 2. Justify true/false: a) Can base class object access member of driven class. b) A base class is never used to create objects. c) Operator overloading is an example of run time polymorphism. d) A class containing virtual function cannot be instantiated. e) Overloading means the use of same name function to the more than one function. 3. What do you mean by virtual destructor? 4. What happens is a derived class fails to explicitly provide arguments to the base class constructor. 5. When do you make class virtual. 6. State the use of protected access identifier. 7. In what order constructors are invoked in multilevel inheritance? 8. Define : pure virtual function. 1. Explain public and private inheritance with example. 2. What is pure virtual function?what are the implementations of making a pure virtual function? 3. What is inheritance?explain multiple and hierarchical inheritance with example. 4. What do you mean by protected access specifiers? Explain protected deviation in detail. 5. What is containership?how does it differ from inheritance? 6. What do you mean by virtual base class and abstract base class? Explain with example. 7. Write short note on constructor in derive class. 8. Create a class vehicle having two private members (vehicle no,,owner name).derive a class two-wheeler having private member (type I.e. scooter/bike).define functions accept and display in both classes. Write a main function to accept detail of two wheelers.(i.e. vehicle name, owner name, type).
Theory Assignments-9 1. Differentiate seekg() and seekup() function. 2. For what purpose,fstream is used? 3. Which class define the file handling method. 4. Which file opening mode should be used to open file only if the file exists? 5. T various classes available for file operations. 6. Define: i) seekg() ii) seekp() 7. 1. What is file? Explain various file stream classes needed for file manipulation. 2. Explain how to open file in C++ program? Describe the various file opening modes. 3. What is file? Describe various approach to detect end-of-file example. 4. Write C++ program to copy contents of two binary files into third file. 5. Accept file name as command line argument. If the file does not exist, display error message. If it exists, display its contents and calculate the length of the longest line in the file. Write a C++ program for above. 6. Write a program in C++ that will create a data file containing the list of telephone numbers and person name.use a class object to store each set of data in following format. Person-Name Telephone-Number ABC 2319554 XYZ 2512279 Theory Assignments-10 1. Sate two advantages of templates. 2. What is function template? 3. It is some times necessary to overload function template. Justify true/false. 4. Give the syntax to create an object of template class. 1. Using generic function, write a C++ program to swap two char or two float variables.