filmov
tv
Java Constructors | No Argument Constructor | Parameterized constructor
![preview_player](https://i.ytimg.com/vi/yk7ij7_v8rg/maxresdefault.jpg)
Показать описание
******************** → A constructor initializes an object when it is created.
→ It has the same name as its class.
→ Constructors have no explicit return type.
→ Java automatically provides a default constructor if there is no explicit constructor.
Types of Java Constructors:
→ No Argument Constructor:
→ It doesn't accept any parameter.
Syntax:
Public class TestClass {
Int num
TestClass() {
num = 10
}
}
Parameterized Constructor:
→ It accepts parameters.
class TestClass {
int x
TestClass(int i) {
x = i
}
}
#Constructor #Java #ProgrammingLine #rake
*******************************************************
IMPORTANT PLAYLISTS:
Important Links:
*******************************************************
Subscribe my YouTube channels:
*******************************************************