Fichas
OOP - Constructors
Fichas del conjunto (9)
- 1Does every class have to have a constructor?Yes, even if you do not make one a default constructor will be created
- 2A Constructor with Arguments create a constructor for a class called Nathan with paramters name, age, and house numberpublic Nathan(String name, int age, int houseNo){
this.name = name;
this.age=age;
this.houseNo=houseNo;
} - 3"this" keyword What is it?A reference to the current object
- 4"this" keyword Does it refer to the instance variable or the Parameter name?instance variable
- 5Overloading What does it mean?The same method/constructor can be defined with more than one signature
- 6Constructors with Arguments What are the 4 benefits?- Create and initialize values in one go
- Quicker for programmer
- Quicker for Application(less operations)
- Less testing - 7Control of Variable Initialization Constructors can be used to apply _____ _____business rules
- 8Default instructor Should you always include one even if there is a constructor that takes parameters?YES
- 9Constructors with Parameters What is the main advantage?Convenience...creating an object and putting in the data in one go
Información
- Descripción
- Masters Programming I Fichas sobre OOP - Constructors, creado por nhunsdale02 el 06/06/2014.
- Creado por
- nhunsdale02
- Visitas
- 21
- Valoración