How do you create a method in java?
Answer / Shashi Kant Srivastava
"In Java, a method is created using the keyword 'public' followed by the return type of the method, the method name, and parentheses containing any parameters. The method body is enclosed within curly braces. Here's an example of a simple method that returns a string:
```
public String myMethod() {
return "Hello, World!";
}
```"
| Is This Answer Correct ? | 0 Yes | 0 No |
strings in java are objects.why?
What do you mean by aggregation?
What is the public field modifier?
Explain the available thread states in a high-level?
What are reference variables in java?
Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.
What is linkedlist in java?
What is instance synchronization?
What is difference between path and classpath?
Why do we create public static method in java?
Can we use catch statement for checked exceptions when there is no chance of raising exception in our code?
Which number is denoted by leading zero in java?