PRASHNIKAप्रश्निका
Back to the paper

Consider the following statement written in class Circle where pi is its data member. static final…

Computer Science20251 markMCQ
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? I. It contains a common value for all objects class Circle. II. Its value is non-changeable. III. At a time two access modifiers, static and final, cannot be applied to a single data member pi.
  • (a)I and II
  • (b)II and III
  • (c)I and III
  • (d)Only III

Answer

Answer

Official answer key

Correct option: (a)

Answer: (a) I and II Since pi is declared static, all objects of class Circle share the one common copy of it, so statement I is valid. Since it is also final, its value cannot be changed once initialised, so statement II is valid. Statement III is false, since static and final can (and often do) apply together to the same data member, exactly as shown here, to create a class-wide constant.
Variables, Expressions

From ISC 2025 Specimen Computer Science Paper 1, question 1(viii).