-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path098-Instance-Method.java
More file actions
45 lines (37 loc) · 1.34 KB
/
Copy path098-Instance-Method.java
File metadata and controls
45 lines (37 loc) · 1.34 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
44
45
/*
* ============================================================================
* Program Name : Instance Method
* File Name : 098-Instance-Method.java
* Class Name : InstanceMethod
*
* Description:
* This program demonstrates the usage of an instance method in Java.
* An instance method belongs to an object of the class and can be
* called only after creating an object.
*
* Objective:
* - Understand the concept of instance methods.
* - Learn how to declare an instance method.
* - Learn how to call an instance method using an object.
*
* Author : Shaik Mahaboob Basha
* Repository : 01-Core-Java
* Folder : 08-Java-Programs
* ============================================================================
*/
public class InstanceMethod {
// Instance method to display a welcome message.
public void displayMessage() {
// Display the welcome message.
System.out.println("Welcome to Core Java Programming!");
}
// The main() method is the entry point of every Java application.
public static void main(String[] args) {
// Create an object of the current class.
InstanceMethod object = new InstanceMethod();
// Call the instance method using the object.
object.displayMessage();
// Example Output:
// Welcome to Core Java Programming!
}
}