If a function in java is declared private then it __________________
Can access the standard output
Can’t access the standard output
Can’t access any output stream
Can access only the output streams
61 practice sets · Page 1 of 4
If a function in java is declared private then it __________________
Can access the standard output
Can’t access the standard output
Can’t access any output stream
Can access only the output streams
Can main() function be made private?
No, because main function is user defined
Yes, if program doesn’t contain any classes
No, never
Yes, always
Which error will be produced if private members are accessed?
Can’t access private message
Code unreachable
Core dumped
Bad code
A private function of a derived class can be accessed by the parent class.
True
False
If private members are to be called outside the class, which is a good alternative?
Not possible
Call a protected member function which calls private function
Call a public member function which calls private function
Call a private member function which calls private function
Which function among the following can’t be accessed outside the class in java in same package?
protected show()
public void show()
static void show()
void show()
Private member functions ____________
Can be accessed only if nested class is private
Can’t be called from enclosing class
Can be accessed only if nested class is public
Can be accessed from enclosing class
How to access a private member function of a class?
Using class address
Using object pointer
Using object of class
Using address of member function
How many private member functions are allowed in a class?
Only 255
As many as required
Only 1
Only 7
In java, which rule must be followed?
Keyword private with arrow before each private member
Keyword private preceding list of private member’s
Keyword private with a colon before list of private member’s
Keyword private preceding each private member
If private member functions are to be declared in C++ then _____________
private(private member list)
private:
private
private :-
Which syntax among the following shows that a member is private in a class?
private::functionName(parameters)
private(functionName(parameters))
private: functionName(parameters)
private functionName(parameters)
Which member can never be accessed by inherited classes?
Private member function
Public member function
All can be accessed
Protected member function
Which among the following is true?
The private members can be accessed only by the private members of the class
The private members can’t be accessed by the protected members of the class
The private members can’t be accessed by public members of the class
The private members can be accessed by public members of the class
Which is private member functions access scope?
Member functions which can’t be accessed inside the class
Member functions which can used outside the class
Member functions which are accessible in derived class
Member functions which can only be used within the class
Passing an object using copy constructor and pass by value are same.
False
True
Is it possible that an object of is passed to a function, and the function also have an object of same name?
No, 2 objects will be created
Yes, life span is different
No, Duplicate declaration is not allowed
Yes, Scopes are different
If an object is passed by address, will be constructor be called?
No, values are copied
No, temporary object is created
Yes, to allocate the memory
Yes, to initialize the members
How many objects can be passed to a function simultaneously?
Only 1
Only an array
As many as required
Only 1 or an array
It is necessary to return the object if it was passed by reference to a function.
No, the changes are made automatically
Yes, since the caller function needs to reflect the changes
No, the changes are made explicitly
Yes, since the object must be same in caller function