filmov
tv
JAVA : What is an interface in Java? SDET Automation Testing Interview Questions & Answers

Показать описание
JAVA : What is an interface 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 an interface in Java?
An interface in Java is a collection of abstract methods that define a set of behaviors that a class must implement.
It provides a contract or agreement between two classes that one class must fulfill the expectations of the other class.
Here's an example of an interface in Java:
public interface Animal {
void makeSound();
}
public class Dog implements Animal {
public void makeSound() {
}
}
public class Main {
public static void main(String[] args) {
Dog dog = new Dog();
}
}
This defines an interface called Animal with a single method called makeSound.
The Dog class implements the Animal interface by providing an implementation for the makeSound method.
In the main method, a Dog object is created and its makeSound method is called, producing the following output:
Copy code
The dog barks.
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 an interface in Java?
An interface in Java is a collection of abstract methods that define a set of behaviors that a class must implement.
It provides a contract or agreement between two classes that one class must fulfill the expectations of the other class.
Here's an example of an interface in Java:
public interface Animal {
void makeSound();
}
public class Dog implements Animal {
public void makeSound() {
}
}
public class Main {
public static void main(String[] args) {
Dog dog = new Dog();
}
}
This defines an interface called Animal with a single method called makeSound.
The Dog class implements the Animal interface by providing an implementation for the makeSound method.
In the main method, a Dog object is created and its makeSound method is called, producing the following output:
Copy code
The dog barks.
Комментарии