Академический Документы
Профессиональный Документы
Культура Документы
Classes:
Ans. No function call is made to inline functions as the source code is copied to the program during
compilation whereas in ordinary functions, the control is switched over to the function block when
function is called.
3. What are the situations where the inline functions do not work?
c. a recursive function
Ans. Structure has only data members whereas class has both data member and member functions.
By default all members of a structure are public whereas all members of a class are private by
default.
5. What is a friend of a class?
Ans. Any ordinary function (non-member of a class) which has access privileges to the private
members of a class are called friends of a class.
Ans. Accessor function – which can only access the data members(not edit it), mutator function –
which can manipulate the data members (getdata(),calculate()), manager function – specific
functions (constructor, destructor)
8. What must be done to make the static data member of a class work?
9. What is the difference between static member function and ordinary member functions:
Ans. Static function of a class can access only the other static members of a class. Static function of a
class is invoked by using the class name instead of object name.
10. How does the memory allocation for member functions and data members take place?
Ans. Member functions are created and placed in memory only once when the class is defined. The
memory is allocated for objects’data members when the objects are declared. All objects share the
same member functions.
Ans. Functions having the same name but which differs in number of type of arguments is called
overloaded functions. It has nothing to do with return types( data type of functions)
13. What contributes to function overloading – function signatures or return type of function –
Ans. function signature
14. Name the various types of constructors- default , parameterized, copy constructor
15. How is a copy constructor called ? Ans – It is called by call by reference only.
Ans- used to defined methods of a class outside the class, to unhide global variable having the same
name as the local variable in a block
Ans. constructors can take arguments but destructor can't , constructors can be overloaded but
destructors can't be overloaded.
20. Write a statement in C++ to prove that even primitive data types have constructors . Ans – int
k(2).
21. What are the privileges of friend function of a class- to access the private and protected
members of a class
22. What happens when constructor functions are invoked – objects are created.
Revision
23. How many ways of representing an integer – decimal, octal and hexadecimal
25. Difference between goto and gotoxy – goto is C++ statement and gotoxy () is a function defined
in conio.h
26. Why is char treated as integer? –memory represents char in ASCII codes(numeric)
28. Name the only data type of which we cannot declare any variables?
Ans. Void
32. Which of the following is not a jump statement? Switch, goto, break, exit.
Ans. Switch.
33. Which of the following will work only in a loop – break, goto, continue, exit.
35. If a function does not have a data type specified which will be its datatype by default ?
Ans. Int
Ans – zero
38. A function that calls itself for its processing is known as – recursive function
39. Strings are character arrays. The last index of it contains the null-terminated character – ‘\0’.
40. What is the only function all C++ programs must contain? – main()
43. What is the difference between int K[2] and int K(2) ?
first is in integer array of size 2 whereas second is declaring a variable K with initial value 2.
44. Differences between abort() and exit() – abort()- aborts “abnormal termination” exit()- closes all
files and writes the buffered output before termination.
45. biggest number that can be represented by – int (32,767) and unsigned int (65,535)
46.
Structure:
Ans. Both structures must be of the same type ( same tag name)
Ans. Typedef creates an alternative name for a standard data type whereas reference creates an
alternative name for a variable.
Inheritance :
51. What is the default inheritance visibility mode? - private (if no visibility is specified it is private)
52. Can a derived class access the private members of the base class? If Yes, how?
55. What is the difference between protected and private members of class –
1 byte.
57. Which operator can be used prove that the private members of the base class are actually
hidden in the derived (visible ) but not accessible?
Ans. Sizeof() operator on the object of the derived class will prove this.
Ans. When a class contains objects of other class types as its members it is called containership
Ans. When a class inherits from another class, the derived has a IS-A relationship with the base class.
When a class contains the object of another class type – then the class containing the object has a
HAS –A relationship with the contained class.
61. When a subclass is a base class of another class it is – multilevel inheritance.
Ans. When a function of base class is re-defined in derived class – it is called function overriding.
File handling:
66. by default all files are treated as – text files in C++ ( not binary)
72. Name the member functions belonging to fstream class – get(), seekp(), seekg()
75. While writing class objects what is written to files data members or member functions?
Ans. Random access is managed by using seekg(), seekp(), tellg(), tellp() functions.
Pointers:
77. What is the difference between constant pointers and pointer to a constant?
79. Which operator is used to refer to the object pointers(class and structure) ?
81. State two situations in which this pointer is not used in classes?
Ans. static member functions do not have this pointer and friend functions are not passed this
pointer
83. What is Static memory allocation and dynamic allocation ? static- at compilation time and
dynamic at run time(using NEW operator)
84. What is life time of dynamically allocated memory variable ? – till it is de-allocated.
85. What is memory leak – if the no. of dynamically allotted memory variable are not deleted using
delete –
Arrays ;
86. How are arrays passed to a function? – by reference/pointers and not by value method
87. What do you mean by traversal – processing all data elements of an array is called traversal.
90. Which are the two ways of memory allocation of a 2-D array – row and column major
91. What is the precondition for a binary search ? – array should be sorted.
93. Which are the two types of queues ? circular and dequeue
Ans. Linear search – demerits takes more iterations to find an element especially if it is towards the
end of array. Array need not be sorted.
96. If arr is an array of integer – is arr++ expression legal – why? (no- base address of a array cannot
be changed)
Q.3.Difference between create table and alter table , create table and create view commands, delete
table and drop table.
Q.1 Universal gates – NAND and NOR . Why are they called universal gates.