• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

a question about Dan's mock

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
abstract class A { // 1
private abstract void m1(); // 2
private abstract class B {} // 3
private class C extends B {} // 4
}

Compiler errors are generated at which of the following lines?
a. 1
b. 2
c. 3
d. 4
e. None of the Above.
the answer is b .but i think is c,d.help!
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
abstract class A { // 1
private abstract void m1(); // 2
private abstract class B {} // 3
private class C extends B {} // 4
}
line //2 (generates compile error):
private and abstract are mutually exclusive modifiers for methods. The private modifier indicates nobody outside of me should see it. The abstract modifier for methods indicates, someone down the line in my class hierarchy should provide the implementation.
line //3 (legal):
class A wants to have an abstract template, which it can use to define some classes. Class A decides that outside the scope of class A, the template (i.e., abstract class B) hasn't got a meaning. So, class A keeps it encapsulated within its boundary.
line //4 (legal):
You can define a private class within a class. It is perfectly legal for class C to extend from private class B as the scope of B is the entire body of class A.
[ December 08, 2002: Message edited by: Abu Yoosuf ]
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic