Overloaded Constructors

Overloaded Constructors

Overloading a constructor means typing in multiple versions of the constructor, each having a different argument lists, like the following examples :

class Foo {
Foo() { }
Foo(String s) { }

The preceding Foo class has two overloaded constructors, one that takes a string, and one with no arguments. Because there\'s no code in the no-arg version, it\'s actually identical to the default constructor the compiler supplies, but remember since there is already a constructor in this class (the one that takes a string), the compiler won\'t supply a default constructor.

Date:2004-03-09 00:00:00

Post Your Answers

User Email:

User Name:

Related scjp1.5 chap6 Links

scjp1.5 chap6 interview questions and answers for experienced and fresher