my dog learned polymorphism
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes could anybody help me to find out the answers for these questions Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "could anybody help me to find out the answers for these questions" Watch "could anybody help me to find out the answers for these questions" New topic
Author

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

Taylor
Greenhorn

Joined: Oct 01, 1999
Posts: 12
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

Joined: Dec 14, 1998
Posts: 19672
    ∞

(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.

permaculture forums
Thandapani Saravanan
Ranch Hand

Joined: Oct 17, 1999
Posts: 117
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


Saravanan
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 19672
    ∞

Right on both counts!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: could anybody help me to find out the answers for these questions
 
Similar Threads
Some Basic Questions
final
ibm test question
instanceof
Are my answers correct ?