Answer to Question #239268 in Java | JSP | JSF for zakia kafeel

Question #239268

Create a Java program that simply outputs the text "Hello World" when you run it. Call your main class

"Application". In the same file as your main "Application" class, define a new class called "Person". You

don't need to put anything in the class. Now, right below where you output "Hello World" in your main

method, create an object from that (Person) class. Modify your "Person" class to add a constructor.

Make the constructor output the text "Constructor running!". Add another constructor in addition to

the constructor it's already got. Make this second constructor accept a parameter called name of type

String. Make this second constructor print the name parameter using System.out.println(). Finally,

change your "main" method, create two objects of Person class and call both constructors.


1
Expert's answer
2021-09-22T00:00:06-0400


package application;




public class Application {


    
    public static void main(String[] args) {
        System.out.println("Hello World");
        Person p = new Person();
        Person per = new Person("Abraham");
    }
    
}
class Person{
    Person(){
        System.out.println("Constructor running!");
    }
    Person(String name){
        System.out.println("The name is "+ name);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS