Computer Applications
Differentiate between instance variable and class variable.
Java Classes
ICSE 2011
56 Likes
Answer
Instance Variable | Class Variable |
---|---|
They are declared without using keyword 'static'. | They are declared using keyword 'static'. |
Each object of the class gets its own copy of instance variables. | All objects of a class share the same copy of class variables. |
They can be accessed only through an object of the class. | They can be accessed using the class name or object. |
Answered By
29 Likes
Related Questions
Differentiate between static data members and non-static data members.
Differentiate between private and protected visibility modifiers.
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.Define a class Triplet with the following specifications:
Class name — Triplet
Data Members — int a, int b, int c
Member Methods:
void getdata() — to accept three numbers
void findprint() — to check and display whether the numbers are Pythagorean Triplets or not.