Constructor :-
·
Constructor can be invoked only one time per object creation by
using
new keyword.
Programmer cannot invoke constructor many times because constructor are
designed
·
Constructor never inherit fields invoke by calling object
·
"constructor" should really be called
an "initializer."
·
Every class has only one constructor
·
There is not any default constructor because of
if we write any thing than this thing can not default also colled parameter less constructor If we are not initialize
any constructor then it make default constructor.
·
A constructor doesn’t have a return type.even
void.they can not return any values.
·
Unlike methods, constructors are not considered
members of a class
·
A constructor is called automatically when a new
instance of an object is created.
·
constructors can have any of the access
modifiers: public, protected, private, or none (often called package or friendly).
·
If we want to implecit call to the operators new and delete.
1:- perameterized constructor:-
Class integer
{
Int m ,n;
Public integer(int x,int y)
}
Integer integers=new integer(4,5);
System.out.println(“”+integers);
2:- copy constructor:-
Is get values same as valu and
assign to in a member variable and this value we can use in to different operations….etc……
Ex:-
Class A{
Int a,b,c;
Public A(int x,int y,int z)
{
…………………
………………….
}
A
d(3,4,5);
A U(A); // constructor copy
3:- Dynamic constructor:-
It initialize memory at run time
No comments:
Post a Comment