0% found this document useful (0 votes)
51 views

Object Oriented Concepts Using C++

This document provides an overview of object-oriented concepts in C++ including classes, objects, encapsulation, inheritance, and polymorphism. It also covers basic C++ concepts like variables, data types, operators, and input/output statements. Some key points include: - Encapsulation binds data and member functions together within an object. Polymorphism allows an object to respond differently to different messages. Inheritance creates new data types from existing ones and allows code reusability. - C++ supports basic data types like int, float, char, and user-defined types like classes. Variables store values and constants cannot be changed. - Input is done using cin and output with cout. Common
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Object Oriented Concepts Using C++

This document provides an overview of object-oriented concepts in C++ including classes, objects, encapsulation, inheritance, and polymorphism. It also covers basic C++ concepts like variables, data types, operators, and input/output statements. Some key points include: - Encapsulation binds data and member functions together within an object. Polymorphism allows an object to respond differently to different messages. Inheritance creates new data types from existing ones and allows code reusability. - C++ supports basic data types like int, float, char, and user-defined types like classes. Variables store values and constants cannot be changed. - Input is done using cin and output with cout. Common
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 11

Chapter 1

OBJECT ORIENTED CONCEPTS USING C++


1. Object model entities in the real world 2. Binding of data and member functions together is called Encapsulations. 3. The ability of an object to respond differently to different messages is called Polymorphism. 4. The process of creating new data types from existing data type is called Inheritance. 5. In computer, the solutions to the problems are of the form programs or application software. 6. Computer program operates on a set of known input data items. 7. Input and output data items are represented in the early programming languages as Variables. 8. Categorization of input data items is defined by Data types. 9. An example of object oriented programming is C++. 10. Behaviour of the object is represented by operation. 11. Which of the following attempts to capture a real world object in a program? Object 12. Which of the following is a group of related functions and data? Object 13. Which of the following is a kind of self-sufficient subprogram with a specific functional area? Object 14. Which of the following is the process of grouping data and its related functions into units? Objects 15. Which of the following mechanism by which the data and functions are bound together within an object definition? Encapsulation 16. Which of the following is the ability of an object to respond differently to different messages? Polymorphism 17. Which of the following data type represents an object in real world? Class 18. Template for entities that have common behaviour is Class. 19. The process of acquiring base class properties is Inheritance. 20. The functionality of a derived class and reusability of the base class is known as Inheritance. 21. Data type allows programs to organize as objects is Class. 22. Which of the following of data provides security to data? Data hiding or abstraction. 23. Which of the following promotes reduces software complexity? Polymorphism. 24. Which of the following is the key factor of object-oriented programming? Function and Object behavior. 25. Objects communicate with one and another by sending data as inputs? 26. OOP stands for Object Oriented Programming. 27. In OOP state refers to physical feature. 28. In OOP behaviour refers to operations. 29. In a calculator the size of the button is refered in OOP as state. 30. In a calculator the process of storing the data in memory is behavior.

31. An example for object Oriented language is C++. 32. An example for non Object Oriented language is Basic.

Chapter 2
OVERVIEW OF C++ 1. C++ was developed at AT & T Bell. 2. C++ was developed in 1980. 3. C++ was developed by Bjarne Stroustrup. 4. C++ was coined by Rick Mascitti. 5. Tokens is the basic types of elements essential for program coding. 6. Token is the smallest individual unit in a program? 7. keywords have special meaning to the language compiler? 8. Which of the following cannot be used as normal identifiers? Keywords. 9. Memory boxes that hold values or constants are called Variables. 10. In C++ a variable must begin with an Alphabet or underscore. 11. Data items whose value cannot be changed are Constants. 12. Numeric constant consists of Whole numbers or decimal numbers. 13. 081 is an example of octal constant? 14. Which of the following value is treated as hexadecimal integer? 0 x F. 15. Floating point constant is a signed real number? 16. Which of the following is a valid real constant? 58.64. 17. E (or) e is used to represent the floating point constant exponent form? 18. Character constant are enclosed with in Single Quotes. 19. Which of the following is not a non-graphic character constant? Alphabet. 20. Constants represented using escape sequences are Non-graphic character. 21. Escape sequences are represented by characters prefixed with a Backslash. 22. Escape sequence used to represent New line is \n. 23. Escape sequence used to represent Null is \o. 24. Literals enclosed by double quotes are String. 25. String are treated as Array of characters? 26. \o character marks the end of a string? 27. Operation to be performed on values are specified by Operator. 28. Constants is an entity. 29. Which of the following operator is not specific to C++? <<= 30. Which of the following operator is specific to C++? .* 31. # and # # operators are used only by the preprocessor? 32. How many classification of operators are there based on operand requirements? 3 33. How many classification of operators are in C++? 13 34. Unary operator required only one operand. 35. Binary operator require two operand? 36. Which operator requires three operand? Ternary. 37. ++ require only one operand? 38. Operators used for mathematical calculations are Arithmetic. 39. % operator gives the remainder of an integer division?

40. All of these are used to form Arithmetic expressions? 41. The logical grouping of operands and operators are called Association. 42. Which of the following operator have the associativity right to left? Prefix ++. 43. a = 3; c = a++; After above statements the value of c is 3. 44. a =3; c = a++; After above statements the value of a is 4. 45. a =3; c =++a; after above statements the value of c is 4. 46. a=7; c=-a; After above statement the value of c is 6. 47. If a=3, b=4, what will be the value stored in the variable of the snippet a=a+b++? 7 48. Relational operators are used to compare values. 49. Minimum Two operands are required to construct a relational expression. 50. Ternary operator is also called conditional operator. 51. In the expression E1 ? E2 : E3 where E1 should essentially be of what type? Scalar 52. = is the simple assignment operator. 53. Evaluate the expression a + = b-c where a=6,b=10,c=5. 11 54. | = operator have an associativity right to left. 55. /**/ characters aretreated as comment when blocks enclosed. 56. C++ statement ends with ; 57. Punctuator used for arrays is []. 58. {} Punctuator is used to group a set of C++ statements 59. Data type can be broadly classified into Three categories. 60. Scalar type is not a data type? (a) User defined type (b) Built-in type (c) Derived type (d) Scalar type 61. User defined data type helps in improving credibility and readability of the Program. 62. Type definition allow users to define a variable that would represent an existing datatype. 63. Meaningful datatype identifiers can be created using Typedef. 64. List of identifiers can be created using Enumerated datatype. 65. Enumerated datatype is also called symbolic numeric constants of the type int. 66. Four specifiers in a storage class. 67. Typedef is not a storage class specifiers. 68. static, register storage class automatically initialized to zero. 69. Auto variables are not initialized with appropriate values based on their datatype. 70. Auto variable get undefined values known as Garbage. 71. Register storage class instructs the compiler to store the variable in the CPU register to optimize access. 72. Extern variable declaration are defined in another program. 73. Auto is a default storage class. 74. Built-in datatype is also called fundamental or basic datatype. 75. Built-in datatype are predefined in the compiler. 76. Three fundamental datatype in C++. 77. Typedef is not a Basic data type. 78. Integral basic data type is further divided into int, char. 79. Char datatype can hold character data and integer data.

80. Float basic data type is further divided into float, double. 81. Void data type the function does not return a variable. 82. Void data type used to declare a generic pointer. 83. Storages classes have a profound effect in the internal representation of date. 84. Derived datatype are built from basic or user defined data type. 85. 32768 to 32767 is the range of int datatype. 86. 8 bytes the double data type occupy. 87. Pointer variable holds a memory address. 88. &, * are the operators that deals with pointer data type. 89. Which of the following is not a unary operator? (a) ++ (b) - - (c) * (d) < 90. _ (underscore) character a variable name begins are reserved for internal system variable. 91. Which of the following is not a valid variable name? (a) abc (b) _abc (c) 2abc (d) abc2 92. Compiler allocates memory for the variable declared. 93. How many words for datatypes in C++? (a) 9 (b) 7 (c) 6 (d) 5 94. How many bits are needed to store integer values in binary form? (a) 2 (b) 4 (c) 8 (d) 16 95. What will be the value of 16th bit if the number is negative? (a) N (b) 0 (c) (d) 1 96. 65535 will be the maximum range of unsigned integer data type. 97. Modifier alters the base data type to yield new data type. 98. Const qualifier specifies the value of a variable will not change during the run time of a program. 99. Size of operator returns the size in term of bytes. 100. Which variables are sensitive to the data type they point to? (a) Pointer (b) Static (c) Size (d) Register. 101. Type cast refers to the process of changing the data type of the value stored in a variable. 102. Type cast is restricted only to fundamental or standard data type. 103. Float x ; x = (float) 7/3; Now the value of x is _______ (a) 4.333 (b) 2.303 (c) 2.333 (d) 3.333 Chapter 3

BASIC STATEMENT
A preprocessor directive starts with # Basic statements in C++ are constructed using Tokens. Reading data in programming is done by Input statement. Data is read from the keyboard during run time using the object Cin. Keyboard is a standard input device. The declaration for the object cin are available in the header file istream.h The basic output operations are managed by a set of declarations available in the header file ostream.h 8. iostream.h file comprises the combined properties of istream and ostream.h. 1. 2. 3. 4. 5. 6. 7.

9. Header file comprises of all standard declarations and definitions for predefined functions. 10. Header files can be included in the program by using Preprocessor directive. 11. >> is the extraction or get from operator. 12. cout is a predefined object of standard output stream. 13. << is the insertion operator or put to operator. 14. Three primary sections are in a C++ program. 15. On successful compilation, when the program is executed Main( ) function will be automatically executed. 16. Pointer variable are defined only when memory is fetched to store data. 17. Assignment statement assign value of an expression to the variable. 18. = is the assignment operators. 19. Program statements that cause a jump of control from one part of the program to another part are called Control structures. 20. How many major category of control structures are there? (a) Four (b) Three (c) Two (d) Five 21. Which of the following are the major category of control structures? (a) Decision making and Looping statements (b) Input and Output statement (c) Operators and Identifiers (d) Punctuators and Keywords 22. ifelse statement chooses between two alternatives. 23. switch decision statement creates branches for multiple alternatives. 24. If is the simplest of all the decision statements. 25. Condition should always be enclosed in brackets. 26. If the action block is compound statements, then it should be enclosed in curly braces. 27. In switch, the last statement in every action block is Break. 28. for execute a set of instructions repeatedly for a certain number of times. 29. A looping block consists of Two segments. 30. A looping block consists of segments namely Body of the loop and Control statements. 31. How many number of classification of loops based on the position of the condition ____________ (a) Two (b) Four (c) Eight (d) Twenty. 32. Loops in C++ are of Three kinds. 33. In exit check loop the condition is placed at the end of action block. 34. In entry check loop the condition is placed at the beginning of action block. 35. continue forces the next iteration of a loop, skipping remaining statements of the action block. 36. For is an entry controlled loop. 37. Source Code is a high level language. 38. Machine readable form of program is called object file. 39. Compiler creates object file from source.

CHAPTER 4:

FUNCTION C++ ENHANCEMENTS


1. 2. 3. 4. Functions are the building blocks of C++ Programs? The starting point for the execution of a program is main( ) Functions reduce the size of the program and induce reusability of program code. Functions can be shared by other programs by compiling and loading them together? 5. Functions should always end with return 6. Declaration of a function is made, through a function prototype. 7. Variables in the function prototype act as place holders. 8. A function can be called or invoked from another function by using its Name. 9. Comma (,) is used separate a set of actual parameters in a function? 10. In a function parameters should be enclosed in parentheses. 11. Call statement communicates with the function through Argument or Parameters. 12. Data flows from call statement to function and vice versa by Parameters. 13. Parameters associated with call statement are called Actual. 14. Parameters associated with function header are called Formal. 15. In Call by value method, the flow of data is always from the call statement to the function definition? 16. When arguments are passed by value, the called function creates new variables. 17. In Call by value method, any change in the formal parameter is not reflected in the actual parameter. 18. In Call by reference method, any change in the formal parameter is reflected in the actual parameter. 19. In Call by reference method, the formal parameters become alias to the actual parameters. 20. In call by value method the actual parameters can be passed in the form of (a) Constants only (b) Variables only (c) Expressions only (d) Any of the above. 21. In call by reference method the actual parameters can be passed in the form of Variables only. 22. How will you declare a functions that returns no value? Void. 23. Which of the following reduces the speed of program execution? Stacks. 24. inline function inserts the functions code directly into the calling program. 25. Inline functions execute faster. 26. Inline functions require more memory space 27. Scope refers to the accessibility of a variable. 28. How many types of scopes are available in C++? Four. 29. Local variable cannot be accessed from outside the block of its declaration? 30. In C++ a block of code should be enclosed in { }. 31. Local variables are not known outside their own code block? 32. Local variables are destroyed upon the exit of its block? 33. Function variable is available to the function block and all sub-1 blocks. 34. file scope variables are available to the entire program.

35. The variable declared above main( ) has the scope file.

Chapter: 5
STRUCTURED DATA TYPE-ARRAYS 1. Array hold several values of the same data type? 2. Array is a collection of variables of the same type referenced by a common name? 3. Arrays are of Two types. 4. One-dimensional array comprises of finite homogenous elements. 5. Multi-dimensional array comprising of elements, each of which is a one dimensional array? 6. The size of the array should always be Positive. 7. 2 bytes required to store one integer 8. The first subscript of element in an array in C++ is 0. 9. In an array ename[5], the last element is referred by ename[4]. 10. The process of rearrange the data in a given array either in ascending or descending order is called Sorting. 11. Strings are otherwise called Literals. 12. Strings are treated as single dimensional array of characters? 13. A character array (used as string) should be terminated with \ 0. 14. Which of the following is used to treat spaces as part of string literal (a) gets( ) (b) getch( ) (c) write( ) (d) getline( ) or gets( ). 15. Gets( ) is defined in member function of standard input stream stdio.h. 16. Contents of string can be displayed by Two methods. 17. Two parameters required for write( ) function in C++. 18. String manipulators are defined in string.h header file? 19. strlen( ) function returns the number of characters stored in the array? 20. strcpy( ) function copies source string to target string? 21. strcmp( ) function compares the two given strings. 22. 2-D array is stored in sequential memory blocks? 23. 1,0 position of 2-D array is same in row-major order and column major order? 24. A two dimensional array of [3][4] can store 12 elements. 25. 16 will be the size of an array a [2][4]. 26. In array initialization int x[ ] [2] = {1,2,3,4,5,6} the number of rows is 3. 27. Matrix is a set of mn numbers arranged in the form of a rectangular array? 28. In 2D-array type of array, matrices can be represented. 29. In 2D-characters array, which of the following determines the number of strings? (a) Rows (b) Columns (c) Last index (d) Second index 30. In 2D-characters array, Column determines maximum length of each string. Chapter:6

CLASSES AND OBJECTS

1. 2. 3. 4. 5. 6. 7. 8. 9.

The most important feature of C++ is the Class. Classes provides a method for packing together data of different types. Class is a way to bind the data and its associated functions together. The functions associated with the class data type is called Methods. How many parts in a class specification? Two. { } braces is used to enclose the body of a class. The body of the class is terminated by a ; The class body contains the declaration of variables and functions. By default the members will be treated as private if a visibility label is not mentioned. 10. The members that have been declared as private can be accessed only within the class. 11. The members that have been declared as protected can be accessed from within the class and inherited classes. 12. The members that have been declared as public can be accessed from outside the class also. 13. The binding of data and functions together in to a single entity is called Encapsulation. 14. Data abstraction is achieved through Data hiding. 15. Data hiding is the key feature of object oriented programming. 16. Class comprises of Members. 17. Data members are data variables that represent the features or properties of a class. 18. Member functions are the functions that perform specific tasks in a class. 19. Member functions are called methods. 20. Data members are called attributes. 21. Private access specifies are used to access friend functions. 22. Class name is also called class tag. 23. In C++, the class variables are known as objects. 24. dot operator(.) operator is used to access the members of a class. 25. The members defined within the class behave like inline functions. 26. Different classes having same function name will have their scope resolved by membership label. 27. The static member variable is initialized to 0 when the first object of its class is created. 28. If it is a static One copy of the member variable is created. 29. Bjarne Stroustrup initially named C++ as C with classes. 30. In C++ functions are also called Methods. 31. Which one of the following language features classes? (a) BASIC (b) Star writer (c) C++ (d) C 32. Declaration and function definitions are two specifications of which of the following _______ (a) data type (b) class (c) comments (d) methods 33. Which of the following is a user defined data type ________ (a) Data (b) Class (c) Public (d) Private

34. The body of the class starts and ends with { and }. 35. Declaration of class member are declared inside the class. 36. The class body has 3 access specifies. 37. Class access specifiers are also known as Visibility labels. 38. Data hiding refers to members & functions of a class are not accessible by members of outside class. 39. Instruments allowing only selected access of components to objects and to members of other classes is called Data abstraction. 40. Members of a class are further classified as Data members and member functions. 41. The private data of a class can be accessed only by member functions of its own class and friend functions. 42. When object of a class are created, separate memory is allocated for member variables only. Chapter: 7,8&9

Polymorphism, Constructors and Destructors, Inheritance


1. The word polymorphism means many forms. 2. Overloading terms means a name having two or more distinct meanings. 3. The ability of the function to process the message or data in more than one form is Function overloading. 4. Which strategy adopted by the compiler when functions invoked in function overloading? (a) Best (b) Match (c) Match Best (d) Best Match 5. Each overloaded functions must differ by the number of parameter or data

type. 6. Operator overloading gives additional functionality to the C++ operators. 7. By using which overloading the functionality of + operator can be extended of strings? Operator. 8. Unary operator can be overload by C++. 9. Operator function must be Member functions or friend functions. 10. basic C++ operators operators can be overloaded. 11. The mechanism of giving special meaning to an operator is called operator overloading. 12. Binary operator overloaded through a member function can take One explicit argument. 13. The overloaded operator must have at least One operand of user defined type. 14. Polymorphism is achieved through Overloading.

15. The ability of a function to process the message or data in more than one

form is called as Function overloading. 16. Each overloaded function must differ Either by number of arguments or by data types of arguments. 17. While invoking functions, if the C++ compiler does not find the exact match of the function call statement then Looks for the next nearest match. 18. In integral promotion, a char data type can be converted to _______________ (a) Integer (b) Float (c) Double (d) All the above 19. In integral promotion, a float data type can be converted to _______________ (a) Integer (b) Double (c) char (d) All the above 20. In integral promotion, a double data type can be converted to Float or integer. 21. The return type of overloaded functions May or may not be same. 22. String concatenation is used in Strcat ( ) function. 23. The functionality of operator like + can be extended using Operator overloading. 24. Operator overloading Does not overrule the original definition of the operator. 25. When overloading operators, the overloaded operator must have At least one operand of user defined type. 26. When binary operators are overloaded, The left side object must be an object of the relevant class. 27. When an instance of class comes into scope Constructor gets executed. 28. Constructor function initializes the Class object. 29. When an instance of class goes out of scope Destructor gets executed. 30. Constructor and destructor functions return nothing. 31. Constructor and destructor are not associated with any data type. 32. Function overloading can be applied for constructors. 33. The constructor with out parameters is called default constructor. 34. Default constructors are referred to compiler generated constructors. 35. The name of the constructor must be same as that of the Class name. 36. Destructor of the function that removes the memory of an object. 37. The constructor is executed automatically. 38. ~ is used as prefix to destructor. 39. Destructors cannot be overloaded. 40. Destructors cannot have arguments 41. How many destructors are allowed in a class? One. 42. Inheritance is the most powerful feature of an object oriented programming language. 43. Inheritance is a process of creating new classes. 44. Inheritance is a process of creating new classes called derived classes. 45. Base class is a class from which other classes are derived.

46. Derived class inherits all the properties of the base class. 47. The main advantage of inheritance is reusability. 48. Which of the following keyword is to define the name of the derived class? (a) class (b) void (c) main ( ) (d) method( ) 49. : must be used between derived and base class. 50. The default visibility mode is Private. 51. Access specifier is also referred as visibility mode. 52. How many types of inheritance are possible? (a) Three (b) Four (c) Five (d) Six 53. When a derived class inherits only from one base class, it is known as Single inheritance 54. When a derived class inherits from more than one base class, it is known as Multiple inheritance. 55. When a class is derived from a class which is a derived class itself is Multilevel. 56. Constructors are executed in the order of inherited class. 57. Destructors are executed in reverse order. 58. Classes used only for deriving other classes are called as Abstract class. 59. Abstract object classes are not declared.

You might also like