Tuesday, March 4, 2014

6. CLASSE S AND OBJECTS

1. Which is a new way of creating and implementing a user defined data type?

(a) Polymorphism (b) Class (c) Encapsulation (d) Inheritance

2. Which provides a new method for packing together data of different types?

(a) Inheritance (b) Encapsulation (c) Polymorphism (d) Class

3. Which is a way to bind the data and it s associated functions together?

(a) Encapsulation (b) Inheritance (c) Class (d) Polymorphism

4. How many parts are there in a class specification?

(a) 4 (b) 3 (c) 5 (d) 2

5. The body of a class is enclosed within a

(a) [ ] (b) < > (c) { } (d) ( )

6. Every class declaration is terminated by

(a) :: (double colon) (b) ; (semicolon) (c) . (dot) (d) , (comma)

7. How many access specifiers are there in a class?

(a) 4 (b) 5 (c) 3 (d) 2

8. The class body contains the declaration of

(a) Variables and Functions (b) Variables and Arrays

(c) Pointers and Functions (d) Functions and Arrays

9. Which of the following class visibility label is optional?

(a) public (b) all the other three choices (c) protected (d) private

10. Which members can be accessed only from within the class?

(a) protected (b) global (c) public (d) private

11. Which members can be accessed from within the class and the members of the inherited classes?

(a) public (b) global (c) protected (d) private

12. Which members can be accessed from outside the class also?

(a) protected (b) global (c) public (d) private

13. The binding of data and functions together into a single entity is referred to as

(a) Data Hiding (b) Abstraction (c) Inheritance (d) Encapsulation

14. Data abstraction in C++ is achieved through

(a) Polymorphism (b) Inheritance (c) Data Hiding (d) Encapsulation

15. Which of the following is achieved through data hiding?

(a) Class Members (b) Class (c) Data Abstraction (d) Polymorphism

16. Class comprises of

(a) Members (b) Data types (c) Pointers (d) Arrays

17. Which of the following are data variables that represent the features or properties of a class?

(a) Data members (b) Structures (c) Arrays (d) Member functions

18 Which access specifier is used to access friend functions?

(a) private (b) protected (c) class (d) public

19. How many classifications of members are there?

(a) 2 (b) 3 (c) 4 (d) 5

20. What are the special member functions of classes?

(a) Constructors and Destructors (b) Constructors and Methods

(c) Constructors and Attributes (d) Constructors and Abstractors

21. In how many ways, the methods of a class can be defined?

(a) 2 (b) 5 (c) 3 (d) 4

22. A member function can call another member function directly is called as

(a) Friend functions (b) Inline functions (c) Nesting functions (d) Recursive functions

23. The variable that is initialized only when the first object of it s class created is

(a) static (b) private (c) protected (d) public

24. The static member variable is initialized to

(a) true (b) 0 (c) 1 (d) false

25. Which is the default access specifier?

(a) private (b) static (c) public (d) protected

26. A class which contains more than one object is called as

(a) Nested objects (b) Linked objects (c) Arrays of objects (d) Multi objects

27. Initially C++ was called as 'C with Classes' by

(a) ken Thompson (b) James Gosling (c) Bjarne Stroustrup (d) Charles Babbage

28. In the class, by default the members will be treated as.

(a) public (b) global (c) private (d) protected

29. The members and functions declared under private are not accessible by members outside the class is referred as

(a) Inheritance (b) Data hiding (c) Polymorphism (d) Encapsulation

30. Instruments allowing only selected access of components to object and to members of other classes is called as

(a) Data Hiding (b) Encapsulation (c) Polymorphism (d) Data Abstraction

31. In C++, the member functions are called as

(a) Methods (b) Attributes (c) Operators (d) Operands

32. In C++, Data members are called as

(a) Member functions (b) Attributes (c) Pointers (d) Methods

33. In C++, the class variables are known as

(a) Constants (b) Functions (c) Methods (d) Objects

34. The members of a class are accessed using the operator

(a) :: (double colon (b) : (colon) (c) , (comma) (d) . (dot)

35. The private data of a class can be accessed only through the member functions of its own class and certain special functions are called as ------------functions.

(a) recursive (b) inline (c) friend (d) nested

36. The members defined within the class behave

(a) inline functions (b) arrays (c) user defined functions (d) structures

37. The memory space required for the float member variable

(a) 8 bytes (b) 1 byte (c) 4 bytes (d) 2 bytes

38. Which member variable’s initial value is done outside the class?

(a) auto (b) static (c) extern (d) register

39. Which data members are not related to any specific object of the class but are shared by all the objects of the class?

(a) public (b) private (c) protected (d) static

40. Which of the following is not a valid class access specifier?

(a) protected (b) private (c) pointer (d) public

41. Which is the key feature of OOPS?

(a) Abstraction (b) Encapsulation (c) Data hiding (d) Data cancelling

42. The function associated with the class data type is called

(a) Arrays (b) Methods (c) Pointers (d) User defined data types

43. Which of the following statements is NOT true ?

(a) The return type of a member function cannot be of object data type

(b) A non-member function cannot access the private data of a class

(c) Several different classes can use the same function name

(d) Member functions can be of static type

44. Which of the following is the part s of a class specification?

(a) Arrays and Functions (b) Pointers and Arrays

(c) Datatypes and Pointers (d) Class declaration and Class function definitions

45.

class product
{
int c, q;
float p;
} p1;
The number of bytes occupied by p1 is

(a) 7 (b) 9 (c) 8 (d) 10

46. The member function declared under ------------ scope can be accessed by the objects of that class.

(a) protected (b) public (c) private (d) global

47. The variable shared by all the objects of a class, it behaves like

(a) Static (b) Private (c) Extern (d) Auto

48. Which of the following is the most important feature of C++?

(a) Function (b) Array (c) Class (d) Pointer

49. Which is used to create user defined data type?

(a) Derived class (b) Base class (c) Data hiding (d) Class

50. How many copy(copies ) of the member variable is (are) created if it is static memory?

(a) Two (b) Three (c) One (d) Four

51.

class product
{
int a,b;
float P;
public:
void assign_data();
void display( );
};

void main( )
{
product P1, P2;
}

The number of memory bytes allotted for the variable P1 is

(a) 8 (b) 12 (c) 4 (d) 10

52. Class name is also called as

(a) function (b) method (c) member (d) tag

53. Which of the following class access specifiers is optional?

(a) Private (b) Protected (c) Public (d) Class

54. How many copy of the member variable is created if it is static memory?

(a) 1 (b) 2 (c) 4 (d) 3

55. Which of the following is true?

(a) Member function cannot be defined outside the class

(b) A class cannot have more than three member functions

(c) Member functions must all have same name

(d) Member function can be defined outside the class also

56. When objects are created, no separate space is allotted

(a) member functions (b) static member (c) data member (d) objects

57.

class example
{
int x,y, z;
float m,n;
}p[5] ;

In the above snippet how many objects are created?

(a) 5 (b) 4 (c) 3 (d) 1

58.

#i nclude <iostream.h>
#i nclude <conio.h>
class item

{
int code, quantity;
float price ;

void getdata( )
{
cout<< "\n Ente r code , quantity and price :";
cin>> code>> quantity>>price ;
}
protected:

void compute ( )
{

if( quantity>100)
tax=2500;

else

tax=1000;
}

public :
float tax;

void putdata( )
{

cout<< "\n Code :"<< code ;
cout<< "\n Quantity:" << quantity;
cout<< "\n Price :" << price ;
cout<< "\n Tax:"<< tax;
}

};

void main()
{
item i;
}

Memory allocation for instance "i" is

(a) 8 bytes (b) 12 bytes (c) 10 bytes (d) 16 bytes

59. public data member in the above class definition is

(a) code (b) price (c) tax (d) quantity

60. Method that can be accessed by object "i" is

(a) putdata() (b) getdata() (c) compute() (d) quantity()

No comments:

Post a Comment