Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Standardmetoder | Interface
Java OOP
course content

Kursusindhold

Java OOP

Java OOP

1. Hvordan Man Arbejder Med IDE?
2. OOP
3. Interface

book
Standardmetoder

Main.java

Main.java

copy
12345678910111213141516171819202122232425
package com.example; public class Main { public interface Greeting { default void sayHello() { System.out.println("Hello from the interface!"); } void greet(String name); } public static class GreetingImpl implements Greeting { @Override public void greet(String name) { System.out.println("Hello, " + name + "!"); } } public static void main(String[] args) { GreetingImpl greetingImpl = new GreetingImpl(); greetingImpl.sayHello(); // Output: Hello from the interface! greetingImpl.greet("Alice"); // Output: Hello, Alice! } }
question mark

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

course content

Kursusindhold

Java OOP

Java OOP

1. Hvordan Man Arbejder Med IDE?
2. OOP
3. Interface

book
Standardmetoder

Main.java

Main.java

copy
12345678910111213141516171819202122232425
package com.example; public class Main { public interface Greeting { default void sayHello() { System.out.println("Hello from the interface!"); } void greet(String name); } public static class GreetingImpl implements Greeting { @Override public void greet(String name) { System.out.println("Hello, " + name + "!"); } } public static void main(String[] args) { GreetingImpl greetingImpl = new GreetingImpl(); greetingImpl.sayHello(); // Output: Hello from the interface! greetingImpl.greet("Alice"); // Output: Hello, Alice! } }
question mark

Select the correct answer

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4
some-alt