πŸ“Š JAVA
Q. Which of the following is the correct syntax for declaring a method in Java?
  • (A) void myMethod() { System.out.println(“Hello”); }
  • (B) public void myMethod() { System.out.println(“Hello”); }
  • (C) myMethod() { System.out.println(“Hello”); }
  • (D) public myMethod() { System.out.println(“Hello”); }
πŸ’¬ Discuss
βœ… Correct Answer: (B) public void myMethod() { System.out.println(“Hello”); }

Explanation: The syntax for declaring a method in Java is to use an access modifier (such as public or private), followed by the return type of the method (such as void or int), the name of the method, and any parameters in parentheses.

Explanation by: Deepak Sahoo
The syntax for declaring a method in Java is to use an access modifier (such as public or private), followed by the return type of the method (such as void or int), the name of the method, and any parameters in parentheses.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
179
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Deepak Sahoo
Publisher
πŸ“ˆ
87%
Success Rate