-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCovarient2.java
More file actions
41 lines (40 loc) · 1.02 KB
/
Covarient2.java
File metadata and controls
41 lines (40 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
class Covarient
{
void fxn0()
{
System.out.println("hello i am no return type fxn ");
}
int fxn()
{
System.out.println("hello i am int return type fxn ");
return 100;
}
char fxn2()
{
System.out.println("hello i am char return type fxn ");
return 'A';
}
float fxn3()
{
System.out.println("hello i am float return type fxn ");
return 3.14f;
}
Covarient fxn4()
{
return this;//this referes to current class obj
}
}
class Main
{
public static void main(String[] args) {
// Covarient obj=new Covarient();
// obj.fxn0();//hello i am no return ......
// System.out.println(obj.fxn());//100
// System.out.println(obj.fxn2());// A
// System.out.println(obj.fxn3());// 3.14
// Covarient obj2; //not initialized only declared
// obj2=obj.fxn4(); //got Covarient class object in return
new Covarient().fxn4().fxn0();//2nd way
// obj2.fxn0();1st way
}
}