jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Some basic questions - part 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Some basic questions - part 2" Watch "Some basic questions - part 2" New topic

Some basic questions - part 2

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

Q3)Which of the following are valid member variable declarations?
a] abstract int i;
b] final int i;
c] final volatile int i;
d] public transient final i
e] protected static final int i
Q4)Which of the following are true regarding interfaces?
a] All methods in an interface are public,abstract and static
b] All interface methods should have public accessibility when implemented in class
c] All variables in an interface are public,static and final
d] interfaces can have constructors
e] It is valid to declare the methods explicitly in an interface as static.

Ajith Kallambella

Joined: Mar 17, 2000
Posts: 5782
Please post one question per thread. Trying to discuss too many things under one topic will convolute the discussion and cannot be of much help to anyone!
Also, when you post questions, think aloud and tell us what you think. Try to answer the question and analize why those answers are right or wrong. This way others can help you re-orient your way of thinking.
These comments apply to all other messages posted by you. You may edit your old messages to separate the questions, or simply post new messages.

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

Here are my answers to the questions:

q3) I think that all the answers are false because a variable cannot be abstract and final variables have to be initialized when they are declared.
Q4) a) false : methods in an interface cannot be static.
b) true : while overriding methods the accessibility cannot be made more restrictive.
c) true : variables in an interface are implicitly public, static and final.
d) false : interfaces cannot be instantiated. So constructors don't come into picture.
e) false : same reason as in a).
natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
I think we can still allow final variables to be declared as posted above, since if they are not initialized, they have to be initialized in the constructors or initializer expressions. I don't think such vague Q.s are asked!!!

Sun Certified Programmer for Java 2 Platform
natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
volatile variables cannot be final!!!
So only option b is correct!!
I agree. Here's the link: http://aspose.com/file-tools
subject: Some basic questions - part 2
It's not a secret anymore!