- C++ supports both classes and structures. Which of the following statements is FALSE in respect of both of them?
Both can have variables and functions as members.
- In both, the members are private by default.
- They support inheritance.
- Their names can be used like any other types names.
- In a class definition, the members declared as private are accessible
- only to the public functions of the class
- to any function in the program
only to functions declared as private
- to all member functions of the class
By default, member functions of a class become
- private
- public
- protected
- inline
- In a class, a member declared as public is accessible
only to public members of the class
- only to member functions of the
- class to any function in the program
- without using objects of the class
- The dot operator is used to connect
a class and a member of that class
- a class object and a member of that class
- a class object and any function
- a class and an object of that class
- Declaration of members as private in C++ enables it to implement the concept
- polymorphism
- modularity
abstraction
- encapsulation
Listed below are some of the possible characteristics of member functions. Which one of them is NOT TRUE?
- All the member functions should be defined within the class itself
- Several different classes can use the same function name
- Member functions can access the private members of the class.
- A member function can call another member function directly without using the dot operator.
- State which of the following is false with respect to classes:
- They permit data to be hidden from other parts of the program
They can directly map objects in the real world
- They bring together all attributes of an entity in one place
- They are removed from memory when not in use
- Which one of the following statements is FALSE?
- A member function defined outside can be made inline using the qualifier inline.
- A member function can be called by using its name alone inside another member function.
- An object of a class can access all its member functions whether they are declared private or public.
- A private member function can only be called by another function that is a member of its class.
- When called by its object, a member function declared as const
- can modify data of only const members.
- can modify data of only non-const members.
can modify data of all members.
- cannot alter any data in the class.
A member function declared as static
- can have access to only other static members of its class
- must be called using only the objects of its class
- can be called using only its class name
- can have access to all members in the same class
Which one of the following statements is
nottrue for a member function declared as friend?- It can be invoked like a normal function without help of any object.
- It cannot access the members of the class directly.
- It cannot have objects as arguments.
- It cannot be called using the objects of its class.
- Which of the following is TRUE about static member variable of a class?
- Each object creates its own copy.
It is visible only within the class.
- It can be initialized whenever necessary.
- It cannot be assigned any initial value at the time of definition.
- Which one of the following is TRUE while passing objects as function arguments?
- A copy of the entire objects can be passed.
- Only the address of the object can be passed.
A nonmember function can use objects as its arguments.
- All of the above.
- Which one of the following is FALSE?
- The address of a class member can be assigned to a pointer variable.
- A class can be defined inside a function.
- When making a member function const, the qualifier const must be used in both declaration and definition.
- None of the above
Answers:
- In both, the members are private by default.
- to all member functions of the class
- private
- to any function in the program
- a class object and a member of that class
- encapsulation
- All the member functions should be defined within the class itself
- They bring together all attributes of an entity in one place
- An object of a class can access all its member functions whether they are declared private or public
- cannot alter any data in the class.
- can have access to only other static members of its class
- It can be invoked like a normal function without help of any object.
- It can be initialized whenever necessary.
- All of the above.
- When making a member function const, the qualifier const must be used in both declaration and definition.
You must log in to post a comment.