JAVA : What is a method in Java? SDET Automation Testing Interview Questions & Answers



JAVA : What is a method in Java? SDET Automation Testing Interview Questions & Answers

JAVA : What is a method in Java? SDET Automation Testing Interview Questions & Answers

JAVA : What is a method in Java?

SDET Automation Testing Interview Questions & Answers

We will be covering a wide range of topics including QA manual testing, automation testing, Selenium, Java, Jenkins, Cucumber, Maven, and various testing frameworks.

JAVA : What is a method in Java?

A method in Java is a block of code that performs a specific task and can be called from other parts of a program.

Here’s an example of how to declare and call a method in Java:

public static void printMessage(String msg) {
System.out.println(msg);
}

public static void main(String[] args) {
printMessage(“Hello, world!”);
}

Output = Hello, world!

The printMessage method in this example takes a string parameter called message, and simply prints it to the console using the System.out.println() method.

The main method then calls printMessage with the argument “Hello, world!”, causing that message to be printed to the console.

Comments are closed.