OOP is an approach that provides a way of modularizing programs by creating
partitioned memory areas for both data and functions that can be used as an templates for creating copies of such modules on demand. 2. List some features of OOP? i. Emphasis is on data rather than procedures. ii. Programs that are divided into what are known as objects. iii. Follows bottom up approach in program design. iv. Functions that operate on the data of an object are tried together in the data structure. 3. Define objects? n entity that can store data and send and receive messages. !t is an instance of a class. 4. What are the basic concepts of OOPs? i. Objects ii. "lass iii. #ata bstraction iv. Encapsulation v. !nheritance vi. Polymorphism vii. #ynamic binding viii. $essage passing i%. 5. Define cass? group of objects that share common properties and relationships. !t is a new data type that contains member variables and functions that operate on the variables. class is defined with a keyword class. !. Define data encapsuation? wrapping up of data and functions into a single unit is known as encapsulation. &. 'hat is inheritance( !t is the process by which objects of one class ac)uire the properties of the another class. ". Define operator o#eroading? *he process of making an operator to e%hibit different behavior in different instances is known as operator overloading. $. Define d%namic binding? #ynamic binding means that the code associated with a given procedure is not known until the time of the call at run time. 1&. 'i#e some ad#antages of OOP(s? i. *hrough inheritance we can eliminate redundant code and e%tend the use of e%isting. ii. "lasses. iii. Easy to partition the work. iv. +oftware comple%ity can easily be managed. 11. What are the object oriented anguages used? Object based programming languages Object oriented programming languages 12. 'i#e some appications of OOPs? i. ,eal time systems ii. +imulation and modeling iii. Object oriented databases iv. "!$-"# systems 13. 'i#e the structure of a )** program? 14. Write a program to dispa% the foo+ing using singe cout statement? ,ame - ... /ge - 23 0incude 1iostream.h2 #oid main34 5 cout116,ame - ...7n6116/ge - 2368 9 15. What is a comment? "omments start with a double slash symbol and terminate at the end of the line. comment may start any where in the line and whatever follows till the end of the line is ignored. 1!. List some to:ens? .eywords/ identifiers/ constants/ strings and operators. 1;. Define structures and casses? <tructures=> hierarchical set of names that refer to an aggregate of data items may have different attributes. )ass=> group of objects that share common properties and relationships. class is defined with a keyword class. 1". Define arra%s? ?ncude fies )ass decaration )ass function definition @ain function program collection of data elements arranged to be inde%ed in one or more dimensions. *he arrays are stored in contiguous memory. 1$. What are the t+o +a%s to create s%mboic constant? 0sing a )ualifier constant #efining a set of integer constants using enum keyword. 2&. What are the ne+ operators used in )**? == <cope resoution operator ==A Pointer to member decaration >2A Pointer to member operator .A Pointer to member operator ne+ Line feed operator deete memor% reease operator set+ Bied +idth operator 21. What are the t+o forms of if statement? 'i#e the s%ntaC aso? *he two forms of if statement are i. +imple if statement ii. !f else statement +ynta%12 Borm 1=> !f3e%pression is true4 5 ction67 8 ction97 Borm 2=> !f 3e%pression is true4 5 ction67 8 Else 5 ction97 8 ction:7 22. What is an eCpression? n e%pression is a combination of operators/ constants and variables arranged as per rules of the language. !t may include function calls which return values. 23. Define :e%+ords? .eywords are e%plicitly reserved identifiers and cannot be used as names for the program variables or other user defined program elements. 24. Define pointers? data type that holds the address of a location in memory. 25. What is an enumerated data t%pe? data type consisting of a named set of values. *he ";; compiler assigns an integer to each member of the set. 2!. What is a main function? ll the ";; programs start with the function main34. Function main returns the integer value that indicates whether the program e%ecuted successfully or not. <%ntaC=> @ain34 5 9 2;. What is the purpose for the return statement? *he return statement is used to return the value from a function. *he statement return <7 returns the value <. *he return statement supplies a value from the called function to the calling function. 2". DCpain function protot%pe? !t is used to describe the function interface to the compiler by giving details such as type number and type arguments and the type of return values. Function prototype is a declaration statement in the calling program. <%nteC=> *ype function=name 3arguments47 2$. What is a ca b% reference? function call mechanism that passes arguments to a function by passing the addresses of the arguments. 3&. Define ca b% #aue? function call mechanism that passes arguments to a function by passing a copy of the value of the arguments. 31. Define macro? short piece of te%t or te%t template that can be e%panded into a longer te%t. 32. What do %ou inine function? function definition such that each call to the function is in effect replaced by the statements that define the function. 33. What are the situations that inine functions ma% not +or:? 6. For function returning values/ if a loop/ a switch/ or a goto e%ists. 9. For function not returning values/ if a return statement e%ists. :. !f function contains static variables. >. !f inline functions are recursive. 34. What are constant arguments? *he )ualifier const tells the compiler that the function should not modify the argument. *he compiler will generate an error when this condition is violated. 35. Define #irtua function? function )ualified by the virtual keyword. 'hen a virtual function is called via a pointer/ the class of the objected pointed to determine which function definition will be used. ?irtual functions implement polymorphism whereby objects belonging to different classes can respond to the same message in different ways. 3!. Define friend function? function that has access to the private members of a class but is not itself a member of the class. n entire class can be a friend of another class. 3;. What the t+o specifications of a cass? *he two specifications of a class are1 "lass declaration "lass function definition 3". What is a cass? group of objects that share common properties and relationships. class is defined with the keyword class. 3$. Eo+ is a member function of a cass defined? $ember function of a class is defined in two places1 6. Outside the class definition 9. !nside the class definition 4&. What are the characteristics of a member function? +everal different classes can use the same function name. *he membership label resolve their scope. $ember functions can access the private data of the class. member function can call another member function directly/ without using the dot operator. 41. Define nesting of member function? member function can be called by using its name inside another member function of the same class is known as nesting of member functions. 42. What are the characteristic of a static data member? 6. !t is initialized to zero when the first object of its class is created. @o other initialization is permitted. 9. Only one copy of the member is created for the entire class and is shared by all the objects of that class no matter how many objects are created. :. !t is visible only within the class/ but its lifetime is the entire program. 43. 'i#e the properties of the static member functions? i. static function can have access to only other static members declared in the same class. ii. static member function can be called using the class name as class name 11 function name 44. Eo+ an object as function argument can be done? *his can be done in two ways1 a. copy of the entire object is passed to the function b. Only the address of the object is transferred to the function. *he first method is called pass by value and the second method is called pass by reference. 45. What are the characteristics of the friend function? i. !t is not in the scope of the class to which it has been declared as friend. ii. !t can be invoked like a normal function without the help of any object. iii. !t has the objects as the arguments. 4!. Define pointer? pointer is a data type that holds the address of a location in memory. 4;. DCpain function o#eroading? Function names can be overloaded in ";;. 'e can assign the same name to two or more distinct functions. 3e.g4 !nt mul3int a/ int b47 Float mul3float %/ float y47 4". Define pri#ate base casses? base class which allows itAs public and protected members to be inherited as private members of the private members of the derived class. *hus the inherited members are accessible to the members and friends of the derived class. But they are not accessible the users of the derived class. 4$. Define defaut argument? n argument value that is specified in a function declaration and is used if the corresponding actual argument is omitted when the function is called. 5&. 'i#e the s%ntaC for caing a member function? Object name . function name 3actual arguments47 51. Define constructor? special member function automatically creating an instance of a class. *his function has the same name as the class. 52. What are the specia characteristics of constructor? *hey shoul be declared in the public section *hey are invoked automatically when the objects are ceated. *hey cannot be inherited. 53. What is parameteriFed constructor? *he constructor that take arguments are called parameterized constructor. 'hen a constructor has been parameterized the object declaration statement such as integer i6 will not work.
54. What are the t+o +a%s in +hich a parameteriFed constructor can be caed? By calling the constructor e%plicitly By calling the constructor implicitly 55. What are the :inds of constructors that +e ca? "onstructor without arguments "onstructor with arguments 5!. What is the ad#antage of using d%namic initiaiFation? *he advantage of using dynamic initialization is that various initialization formats can be provided using overloaded constructors. 5;. What are cop% constructors? DCpain +ith eCampe? *he constructor that creates a new class object from an e%isting object of the same class. Eg12 integer i93i64 or integer i9 C i6 would define the object i9 at the same time initialize the values of i6. 5". Define destructor? function that is called to deallocate the memory of the objects of a class. 5$. List the difference bet+een constructor and destructor? "onstructor can have parameters. *here can be more than one constructor. "onstructors is invoked when from object is declared. #estructor have no parameters. Only one destructor is used in class. #estructor is invoked up on e%it program. !&. Define d%namic constructor? llocation of memory to objects at the time of their construction is known as dynamic constructor. !1. What is the ad#antage of using d%namic initiaiFation? *he advantage of using dynamic initialization is that various initialization formats can be provided using overloaded constructor. !2. Define operator o#eroading? language feature that allows a function or operator to be given more than one definition. For instance ";; permits to add two variables of user defined types with the same synta% that is applied to the basic types. *he mechanism of giving such special meaning to an operator is known as operator overloading. !3. 'i#e the operator in )** +hich cannot be o#eroaded? i. +izeof 2Dsize of operator ii. 11 2Dscope resolution opertor iii. (1 2D conditional operator iv. . 2D$embership operator v. .E 2Dpointer to member operator !4. Eo+ can +e o#eroad a function? 'ith the help of a special operator called operator function. *he general form of an operator function is1 ,eturn type class name 11 operator op3arg list4 5 Function body 8 !5. 'i#e an% four rues for operator o#eroading? 3i4 Only e%isting operators can be overloaded. 3ii4 *he overloaded operator must have at least one operand that is of user defined type. 3iii4 'e cannot used friend functions to overload certain operators. 3iv4 Overloaded operators follow the synta% rules of the original operators. !!. What are the steps that in#o#es in the process of o#eroading? "reates a class that defines the data type that is to be used in the overloading operation. #eclare the operator function operator op34 in the public part of a class. #efine the operator function to implement the re)uired operation. !;. What are the restriction and imitations o#eroading operators? Operator function must be member functions are friend functions. *he overloading operator must have atleast one operand that is of user defined datatype. !". 'i#e a function o#eroad a unar% minus operator using friend function? Frinend void operator 3space Fs4 5 s.% C 2s.%7 s.y - >s.%8 s.F - >s.F8 9 !$. Define unar% and binar% operator o#eroading? Overloading without e%plicit arguments t an operator function is known as 0nary operator overloading and overloading with a single e%plicit argument is known as binary operator overloading. ;&. DCpain o#eroading of ne+ and deete operators? *he memory allocation operators new and delete can be overloaded to handle memory resource in a customized way. *he main reason for overloading these functions is to increase the efficiency of memory management. ;1. Define t%pe con#ersion? conversion of value from one data type to another. ;2. What are the three t%pes of con#ersion ta:es pace? "onversion from basic type to class type "onversion from class type to basic type "onversion from one class type to another class type. ;3. When and ho+ the con#ersion function eCists? *o convert the data from a basic type to user defined type. *he conversion should be defined in user defined objectAs class in the form of a constructor. *he constructor function takes a single argument of basic data type. ;4. 'i#e the s%ntaC for o#eroading +ith friend functions? Friend return type operator op3arguments4 5 Body of the function 8 ;5. Define inheritance? *he mechanism of deriving a new class from an old one is called inheritance. *he old class is referred to as the base class and the new one is called the derived class or the subclass. ;!. What are the t%pes in inheritance? i. +ingle inheritance ii. $ultiple inheritance iii.$ultilevel inheritance iv. Gierarchical inheritance v. Gybrid inheritance ;;. DCpain singe inheritance? derived class with only one base class is called single inheritance ;". What is mutipe inheritance? derived class with more than one base class is called multiple inheritance. ;$. Define hierarchica inheritance? One class may be inherited by more than one class. *his process is known as hierarchical inheritance. "&. What is h%brid inheritance? *here could be situations where we need to apply two or more type of inheritance to design a program. *his is called hybrid inheritance. "1. What is mutie#e inheritance? *he mechanism of deriving a class from another derived class is known as multilevel inheritance. "2. What is #irtua base cass? *he child has two direct base classes parent6 and parent9 which themselves have common base class grand parent. *he child inherits the traits of grand parent via two separate paths. !t can also inherits directly shown by the broken line. *he grand parent is sometimes referred to as indirect base class. "3. What is abstract cass? n abstract class is one that is not used to create objects. n abstract class is designed only to act as a base class. !t is a design concept is program development and provides a base upon which other classes may be built. "4. What is nesting of casses? class can contain objects of other classes as its members. !t is called nesting of classes. "lass 5H.87 "lass B 5 a7 87 "5. What is po%morphism? Polymorphism is one of the crucial feature of OOP. !t simple means one name multiple forms. !t contain run time polymorphism and compile time polymorphism. "!. What are the t%pes of po%morphism? ,un time polymorphism "ompile time polymorphism ";. What is compie time po%morphism? *he overloaded member function are selected for invoking by matching arguments both type and number. *his information is known to the compiler at the compile time and therefore compiler is able to select the appropriate function for a particular call at the compile time itself. *his is called early binding or static binding or static linking. lso known as compile time polymorphism. "". What the t%pes in compie time po%morphism? Function overloading Operator overloading "$. What is this pointer? uni)ue keyword called this to represent an object has invokes a member function. $&. What is #irtua function? *he same function same in both the base and derived classes the function in base class is declared as virtual using the keyword virtual preceding its normal function declaration. $1. What are the rues for #irtua function? 6. *hey cannot be static members 9. *hey are access by using object pointers :. virtual function can be a friend of another class. $2. What is pure #irtua function? pure virtual function is a function declared in a base class that has no definition relative to the base class. $3. What are the fie stream casses in )**? 6. filebuf 9. fstreambase :. ifstream >. ofstream I. fstream $4. What are the fie manipuation function in )**? i. seekg34 ii. seekp34 iii. tellg34 iv. tellp34 $5. What are the fie open modes? !os11app/ ios11binary/ ios11out/ ios11in/ ios11ate/ ios11nocreate/ ios11noreplace/ ios11trunk. $!. What are the error handing function in )**? 1. eof34 9. fail34 :. bad34 >. good34 1! mar:s 1. Describe principes of object oriented programming? a. "lasses group of objects that share common properties and relationships. !t is a new data type that contains member variables and functions that operate on the variables. class is defined with a keyword class. b. Objects c. bstraction d. Encapsulation wrapping up of data and functions into a single unit is known as encapsulation. e. !nheritance !t is the process by which objects of one class ac)uire the properties of the another class. f. Polymorphism g. #ynamic binding #ynamic binding means that the code associated with a given procedure is not known until the time of the call at run time. h. $essage passing 2. DCpain object oriented anguages? a. Object based programming languages b. Object oriented programming languages 3. What are the appications of OOPs? dvantages12 i. *hrough inheritance we can eliminate redundant code and e%tend the use of e%isting. ii. "lasses. iii. Easy to partition the work. iv. +oftware comple%ity can easily be managed. /ppications=> ,eal time systems ii. +imulation and modeling iii. Object oriented databases iv. "!$-"# systems 4. DCpain inheritance concept? <inge inheritance $ultiple inheritance $ultilevel inheritance Gierarchical inheritance Gybrid inheritance 5. DCpain po%morphism? "ompile time polymorphism ,un time polymorphism