Advertisements
Advertisements
प्रश्न
Consider the following statement written in class Circle where pi is its data member.
static final double pi = 3.142;
Which of the following statements are valid for pi?
- It contains a common value for all objects class Circle.
- Its value is non-changeable.
- At a time two access modifiers, static and final, cannot be applied to a single data member pi.
पर्याय
I and II
II and III
I and III
Only III
MCQ
उत्तर
I and II
Explanation:
Statement I and Statement II are valid because pi is static, meaning it contains a common value for all objects of the class Circle, and pi is final, meaning its value is non-changeable.
shaalaa.com
Object as an Instance of a Class
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?