• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Scjp Queries  RSS feed

 
Ranch Hand
Posts: 634
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
q1.Is it necessary for a class with final instance variable to be initialised before they are used ??

q2.is final variable a compile time constant ??

q3.do compile time constants need to be given a value before they are used ??

q4. what access modifiers can be for local modifiers ??
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

mohitkumar gupta wrote:q1.Is it necessary for a class with final instance variable to be initialised before they are used ??

q2.is final variable a compile time constant ??

q3.do compile time constants need to be given a value before they are used ??

q4. what access modifiers can be for local modifiers ??



ans to q1: Yes they have to be initialized
ans to q2:Yes
ans to q3: Yes..for eg,the case in switch statement is a compile time constant.
ans to q4:No
 
Ranch Hand
Posts: 432
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
q1.Is it necessary for a class with final instance variable to be initialised before they are used ??
ans:yes

q2.is final variable a compile time constant ??
ans:yes

q3.do compile time constants need to be given a value before they are used ??
ans:yes,offcourse.

q4. what access modifiers can be for local modifiers ??
your question is wrong
it should be: what access modifiers can be for local variables??
ans:you can use default,only final modifier is applicable to local variable if you want to use.
 
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All the other questions got the answers, but the below is somewhat strange.

mohitkumar gupta wrote:
q1.Is it necessary for a class with final instance variable to be initialised before they are used ??



What you are asking? What you are going to initialized before used? final instance variables or objects?
 
Sheriff
Posts: 9643
42
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

q2.is final variable a compile time constant ??


Sometimes yes but there are certain conditions. Check this tutorial...
 
Are you okay? You look a little big. Maybe this tiny ad will help:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!