You are on page 1of 16
VIVA VOCE QUESTIONS . Distinguish between an object and a class. . . An object is an identifiable entity with some characteristics and behaviour. It Tepresents an entity that can store data and its associated functions, . A class is a group of objects that share common properties and relationships. It represents a group of similar objects. » What do you understand by procedural programming paradigm and objéct. oriented programming paradigm ? + Procedural programming paradigm aims more at procedures. The emphasis is an doing things rather than the data. Object oriented programming paradigm is based on the principles of data hiding, abstraction, inheritance, and polymorphism. It implements programs using classes and objects, . Why is data considered safe if encapsulated ? (mpt) Ans. Encapsulation ensures that only authorised functions access the relevant data. The safety against unauthorised access ensures data safety. . Why are classes called Abstract Data Types ? Umpt) Ans. Classes use the concepts of data abstraction, thetefore, these are called Abstract data types, . ‘Data types’ because various objects can be created of a class type same way as various variables are created of a data type. . How are abstraction and encapsulation inter-related ? Ans, Encapsulation wraps up data and functions under single unit and ensures that only essential features get represented without representing the background details. Therefore, entcapsula- tion is a way of implementing abstraction. » How does OOP overcome the shortcomings of traditional programming approaches ? The traditional programining approaches emphasize more on doing things, The algorithm for the solution plays a key role here. The data is not given as much concern as required. Data is after all, the reason for a program’s existence. The important part of an inventory Program isn’t a function that displays or checks data ; itis the inventory data itself, Yet data is given second-class status while ptogramming. Another problem associated with traditional programming languages is that they do not model the reat world very well. For instance, in brary management a procedural program would emphasize more on procedures Issue, Refurn etc. whereas the real world entitiee are Books. But ‘Books’ are given second-class status in the program. ‘The OOP overcomes these shortcomings by () giving data the prime consideration and (i) modelling the real world entities into classes and objects. It is the data (and associated functions) that is the key factor while declaring classes. And the real world behaviour is reflected through objects and their properties. . How are data and functions organised in an object oriented program ? (CBSE Question Bank 1998) » The data and associated functions are encapsulated in.a single unit known as class. Only the member functions and friend functions can have access of data inside the class, otherwise Ans. 10, Ans. i 12. 13. Ans. the data remain hidden from outside world, This ensures security and safety of the data. There are visibility modes.also in a class that also control over the access privileges of data and fanctions. . What is the difference between ‘a’ and “a” in C++? Characters enclosed in single quotes are character constants in’ C++. Thus ‘a’ is a character constant, Characters enclosed in double quotes are string-literals which are array of characters. Thus “a is a string ie. in memory “a” is represented as “a\0" where \O (null) character is the terminator of the string. The size of ‘a’ is 1 byte whereas the size of “a is 2 byte. ). Why is char often created as integer data type ? The memory implementation of char data type is in terms of the number code (eg. ASCII code which is integer). Therefore, it is said to be another data type. How many ways are there in C++ (o represent an integer constant ? In C++, an integer constant can be represented in 3 ways : 1. As a decimal integer constant in which the integer constant consists of a sequence of digits but it does not begin with digit 0 (zero), For example, 1234 is a decimal integer constant but 01234 is not a decimal integer constant. 2. As an octal integer constant in which the integer constant begins with digit 0 (zero). For example, 9 (in decimal} can be written as 011 (octal equivalent of 9) as octal intege: 3. As a hexadecimal integer cnstant in which the integer begins with Ox or OX. For instance, 11 (in decimal) can be written as OXB (hexadecimal equivalent of 11). What is the use of pre-processor directive - #include in a C++ program ? (CBSE- Question Bank 1998) . The header file iostream.h is included in a C++ program through this pre-processor directive. It is done to implement input/output facilities, Input /output facilities are not defined within C++ language, rather are implemented through a component of C++ standard library, instream.t. The file iostreumh consists of declarations of standard stream input and output facilities. It also consists of procedures that predefine a set of operations for handling reading and writing of built-in data types. What is the role of main () in C++ program ? . Whenever a C++ program is executed only the main ( ) is executed ie,, execution of the program starts and ends at main ( ). The main () is the driver function of the program. If it is not present in a program, no execution can take place. . An unsigned int can be twice as large as the signed int. Explain how ? : An unsigned int (size 2 bytes) can represent 0 to 65,535 ic., 65,536 values in total whereas a signed int can represent ~32768 to 32767 ie, 65,536 values in total. The total numbers represented by both (signed and unsigned) integers are the same, however, the range represented by..nisigned int becomes double because in place of negative values, new posi- * tive values are représenied thereby incieasing the range by 32768 numbers as there ate these many negative values represented by signed int. i. 45. 16. Ans. VW." Ans. 18. Ans. 19. Ans. 20, Ans. é. Inan entry Explain briefly the difference between an entry controt loop and exit control loop. mirol loop, the test expression is evaluated before entering into a loop ( before executing the body of the loop) whereas in an exit-control loop, the test expression, is evaluated before exiting from the loop. The for and while loops are entry-control loops and do-while is exit-control foop. The for and while loops are not entered even fer once when the test expression is false (i.e. zero) but the exit control loop do-while is executed at least once even if the test expression is false. What is an inline function ? (CBSE Question Bank 1998) ‘Ans, An infine function, is that which is not invoked (i¢., loaded afresh) at the time of, function call rather its code is replaced in the program at the place of function call. Thus, inline functions save the overheads of a function call, Differentiate between CALL by reference and CALL by value. . (CBSE Question Bank 1998) In call by value method, the called function creates its own copies of original values sent to it. Any changes, that are made, occur on the called function's copy of values and are not reflected back to the calling function. . . In call by reference method, the called function accesses and works with the original values using their references. Any changes, that occur, take place on the original values and are reflected back to the calling code. Is prototyping mandatory in C++ program. Justify your answer, (CBSE Question Bank 1998) Yes, prototyping is mandatory in C++. C++ makes it mandatory to ensure proper invocation of functions and prompt error reporting. When will you make a function infine and why ? A function is made inline when the following features are there : (i) the function is small (i) the function is not retuming any value and contains no return statement. (i) the function does not contain a loop or a switch or a goto. (ir) the function does not contain static variables. (@) the furietion is not recursive. The inlink functions run a little faster than the normal functions as function-calling over heads are saved. : Why is C++ standard library needed? . The C++ language, contains some statements only and not any builtin functions. Various functions (that are not part of the basic C++ language) that help perform 1/0 operations and some other operations, that can't be directly performed using C++ basic statements, are stored together in form of a library, the standard library. These stored functions can be called and used for the desired operations by including the desired library file into the program. What is the function cf these header files : iomanip.h, string.h, ctypeh, math.h iomanip-h. This header file declares the C+ streams, 1/O manipulator and contains macros for creating parameterised manipulators ‘ string.h. This header file declares several string manipulation and memory manipulation routines.

You might also like