By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,651 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,651 IT Pros & Developers. It's quick & easy.

How can you define the classes Adult, Student and Engineer ?

P: 1
How can you define the classes Adult, Student and Engineer so that the next sequence to give compilation error only where specified?

Expand|Select|Wrap|Line Numbers
  1. class Test {
  2. public static void main(String args[]) {
  3. Adult a = new Student(); //without giving compilation error
  4. Adult b = new Engineer();//without giving compilation error
  5. a.explorare(); //without giving compilation error
  6. b.explorare(); //without giving compilation error
  7. a.afisare(); //without giving compilation error
  8. b.afisare(); //compilation error
Nov 17 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.