473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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
0 1152

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

Similar topics

9
by: Zunbeltz Izaola | last post by:
Hi to all! I wonder if it possible (i'm sure python can do :-) ) to define classes on runtime. My problem (schematically) is the folowwin. The User can choise betwenn 3 property of an object....
6
by: Steven T. Hatton | last post by:
As I was reading through some of the stuff in the Standard, I started to wonder if there might be reason to define classes in response to runtime conditions, say, to match some kind of new data...
9
by: Aguilar, James | last post by:
I know that one can define an essentially unlimited number of classes in a file. And one can declare just as many in a header file. However, the question I have is, should I? Suppose that, to...
4
by: David Ross | last post by:
In the same style-sheet, there are two classes with some properties that have differing values. If I have a CLASS attribute on an element that refers to both classes, how should the conflict be...
7
by: alternativa | last post by:
Hello, I have a few questions concerning classes. 1) Why some people use default constructos, i.e constructors with no parameters? To me it doesn't make any sense, is there something I should...
0
by: Greatrebel | last post by:
Hi all, I am trying to use vector iteration to access the member function of a variable length array, the codes as following: vector<slave_cpu> slave_array; for (i = 0; i < n_slave;...
19
by: adriancico | last post by:
Hi I am working on a python app, an outliner(a window with a TreeCtrl on the left to select a document, and a RichTextBox at the right to edit the current doc). I am familiarized with OOP...
4
by: indiaj0nes | last post by:
Hi, I am Supposed to be reading from a student file and store it in array of pointers to student Objects(Objects of Student class). The file contains data like: 102022 Jonathan James L...
11
by: allendowney | last post by:
Hi All, I am working on a revised edition of How To Think Like a Computer Scientist, which is going to be called Think Python. It will be published by Cambridge University Press, but there...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.