-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12_ObjectCreation.java
More file actions
43 lines (37 loc) · 1.2 KB
/
12_ObjectCreation.java
File metadata and controls
43 lines (37 loc) · 1.2 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
42
43
/*
*WAP to Display Object Creation
*/
package javaprograms;
/**
*
* @author Geeky Keshav
*/
public class ObjectCreation
{
public static void main(String [] args)
{
System.out.println("This is my First Message.");
ObjectCreation obj1=new ObjectCreation();
/**Explanation of above line**
*'ObjectCreation' is the class name in which object is created.
* 'obj1' is the object name.
* 'new' is a java keyword to create objects.
* 'ObjectCreation()' is known as constructor.
*/
obj1.show(); //Method calling
obj1.show1();
}
public void show()
{
System.out.println("This is the 2nd Message called through an object 'obj1' with function 'show'.");
}
public void show1()
{
System.out.println("This is the 3rd Message called through the same object 'obj1' but with another method/function 'show1'.");
}
}
/**********OUTPUT*********
This is my First Message.
This is the 2nd Message called through an object 'obj1' with function 'show'.
This is the 3rd Message called through the same object 'obj1' but with another method/function 'show1'.
*/