Prashnikaप्रश्निका
Code
About
‹ Back to the paper

Question 1(viii)

1 mark

Computer ScienceISC 2025 Specimen Computer Science Paper 1MCQVariables, Expressions

Choose the correct option.

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

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.