Computer Applications
Differentiate between private and protected visibility modifiers.
Java Classes
ICSE 2010
ICSE 2012
45 Likes
Answer
Private members are only accessible inside the class in which they are defined and they cannot be inherited by derived classes. Protected members are also only accessible inside the class in which they are defined but they can be inherited by derived classes.
Answered By
25 Likes
Related Questions
Why can't every class be termed as user defined data type?
Differentiate between static data members and non-static data members.
Differentiate between instance variable and class variable.
Define a class Calculate to accept two numbers as instance variables. Use the following member methods for the given purposes:
Class name — Calculate
Data members — int a, int b
Member methods:
void inputdata() — to input both the values
void calculate() — to find sum and difference
void outputdata() — to print sum and difference of both the numbers
Use a main method to call the functions.