You're asked to complete a simple Java program based on the object-oriented programming principles you've learned. The program is designed to print a custom "Hello, world!" message. To do this, a class named 'HelloWorld' has been created, however, the code is not complete. Fill the blanks to properly define the 'HelloWorld' class, instantiate an object of it, and call its getMessage method to print the 'Hello, world!' message.
Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members
Defining classes
Completing a simple 'Hello, World!' program
Report a typo
Fill in the gaps with the relevant elements
HelloWorld {
String message;
public HelloWorld(String message) {
this.message = message;
}
public String getMessage() {
return this.message;
}
public static main(String[] args) {
HelloWorld helloWorld = HelloWorld("Hello, world!");
System.out.println(helloWorld.getMessage());
}
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.