PDA

View Full Version : help for the following statement


nitinm
05-03-2008, 05:19 PM
can please any one tell me what is the meaning of the below statement

1) Account acc;

2) Account acc = new Savings Account;

can the second statement be applied for abstract classes
as i have heared abstract classes cannot be instantiated but we can create objects:confused: :confused: :confused:

ray|raven
05-03-2008, 05:23 PM
The first statement creates an object of the class Account.
The second one instantiates it;although i dont think the syntax is right.
Abstract classes can have objects created and not instantiated.
The second statement cant be used for abstract classes.

Pathik
05-03-2008, 08:03 PM
^^ Exactly.
can please any one tell me what is the meaning of the below statement

1) Account acc;

2) Account acc = new Savings Account;

can the second statement be applied for abstract classes
as i have heared abstract classes cannot be instantiated but we can create objects:confused: :confused: :confused:

BTW Creating an object is the same as instantiating a class.
and yea the 2nd statement should be
Account acc= new Account;
If I am not missing anything.

redhat
05-03-2008, 08:27 PM
^^+1
Wrong Syntax in 2nd statement
It must be "Account acc= new Account;"

Zeeshan Quireshi
05-03-2008, 08:42 PM
Wrong ! :lol:

acc = new Account();

as acc has already been declared n we need to use the brackets to call the contructor :lol: