Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

could anybody help me to find out the answers for these questions

 
Taylor
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q)The static modifier is valid for
a) Class declarations
b) Class initialization blocks
c) Local variable declarations

Q)Consider the following code:

a)5
b) Compiler error, you cannot change a final variable
c) Compiler error, you cannot subclass from Cat
d) 6

[This message has been edited by Paul Wheaton (edited October 19, 1999).]
 
paul wheaton
Trailboss
Pie
Posts: 21183
Firefox Browser IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(I gave your code sample a little formatting so it would be easier to understand)
Q1) Inner class declarations and class initialization blocks.
Q2) You could just copy this program into a couple of .java files, compile and run...
In my head, I think the answer will be 5.
 
Thandapani Saravanan
Ranch Hand
Posts: 117
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think i have two findings in your code.
First, the variable c is an instance variable in TestIt and can not be accessed inside a static method like main.
Second, even if we declare/define 'c ' inside main then we encounter the problem "Can't assign a value to a final variable: c"
So, to me, the question looks like a wrong one.
What do you think?
Rgds,
Saravanan
 
paul wheaton
Trailboss
Pie
Posts: 21183
Firefox Browser IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right on both counts!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic