• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Uni Exam Question

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This one appeared on a Uni Exam paper

Which of the following declares a named constant?

a.final int MAX_STUDENTS;
b.int final MAX_STUDENTS = 1000;
c.int final maxstudents = 1000;
d.final int MAX_STUDENTS = 1000;

There should be only one answer.

Stephen Batsas
SCJP, SCWCD
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would go for D

final int MAX_STUDENTS = 1000;

 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both A and D "declare" a named constant.

Although D goes further and defines the constant, A is a perfectly valid declaration (presumably deferring valuation to the constructor). So in the context of this question, I don't see that there is a single "best answer."
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic