Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Some Basic Questions

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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;

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with sasi except on Q2. b is not correct because abstract methods have a semicolon, not curly braces.
 
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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???
 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!
 
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
natarajan,
I don't see the word "abstract" in option c.
-Peter
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic