How do you call non shared methods of a class

  1. Directly invoking the method name

  2. Invoking the method through the instance of that class

  3. None of the above


Correct Option: B
Explanation:

To call non-shared methods of a class, the user needs to know the concept of object-oriented programming and the difference between shared and non-shared methods. Non-shared methods are specific to an instance of a class, while shared methods are accessible by all instances of a class.

Now, let's go through each option and explain why it is right or wrong:

A. Directly invoking the method name: This option is incorrect because invoking a non-shared method directly through the method name will result in a compilation error. Non-shared methods require an instance of the class to be created first before they can be accessed.

B. Invoking the method through the instance of that class: This option is correct. To call a non-shared method, you need to create an instance of the class and then call the method through that instance. This allows the method to access the instance's specific data and perform actions specific to that instance.

C. None of the above: This option is incorrect because option B is the correct way to call non-shared methods.

Therefore, the answer is: B. Invoking the method through the instance of that class.

Find more quizzes: