This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Some Basic Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Some Basic Questions" Watch "Some Basic Questions" New topic
Author

Some Basic Questions

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

Hi everybody,
I am sorry to have posted 10 questions in one post.

Here are two of them :

Q1) State true or false :
protected access is provided even to subclasses that reside in a different package from the class that owns this feature.
Q2) Which of the following are valid method declarations?
a] abstract native void method();
b] abstract void method(){}
c] public static final void method(){}
d] abstract public synchronized void method();
e] public void abstract method();
f] public abstract void method() throws ArithmeticException;

sasi dhulipala
Ranch Hand

Joined: Dec 28, 2000
Posts: 31


Q1) State true or false :
protected access is provided even to subclasses that reside in a different package from the class that owns this feature.
The answer is true protected variables can be accessed from subclasses in different packages.
Q2) Which of the following are valid method declarations?
a] abstract native void method();
b] abstract void method(){}
c] public static final void method(){}
d] abstract public synchronized void method();
e] public void abstract method();
f] public abstract void method() throws ArithmeticException;
I say b,c are correct. d is also correct and f is also correct.
a is incorrect and e is also incorrect method has to retrun some value. it is returning abstract here
native methods cannot be abstract
Sasidhar
Scott Kiel
Greenhorn

Joined: Jan 05, 2001
Posts: 15
I agree with sasi except on Q2. b is not correct because abstract methods have a semicolon, not curly braces.
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
For Question 2.
A. False - Abstract methods can't be native
B. False - Abstract methods can not have bodies {}
C. True - Nothing wrong with this
D. False - Abstract methods can not be synchronized
E. False - Return type (void) must be right before method name.
F. True - Can throw exceptions in abstract methods.
So C and F are correct.
Bill
amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231

To Bill,
I think that c) is also incorrect because method declarations cannot have curly braces, they have to end with a semicolon.

Am I true???
natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
C is totally incorrect since abstract methods cannot have a body.
thanks for letting me know that abstract methods can't be syncronized. But i just found that native methods can be syncronized!!.
So here only F is the right choice!!

Sun Certified Programmer for Java 2 Platform
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
natarajan,
I don't see the word "abstract" in option c.
-Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Some Basic Questions
 
Similar Threads
the difference of a method as void and not void concern a abstrct method.
abstract method overriding
Access Modifier for Methods
regarding class definition
Please help me !!!!!answers for sun sample questions