Question: run both code in java and take capture put both code in dr java and take capture Purpose: a class provides the blueprints for objects.
Purpose: a class provides the blueprints for objects. So basically, an object is created from a class. In Java, the new keyword is used to create new objects. First Java Program First Java Program Let us look at a simple code that will print the words Hello World. public class MyFirst Java Program /* This is my first java program.* This will print 'Hello World' as the output */ public static void main(String (jargs) { System.out.println("Hello World"); // prints Hello World ? The output Welcome to DrJava. Working directory is D:Dr.Nadir Kamal PROGRAMMINGI practical execution > run MyFirst JavaProgram Hello World Following is an example of creating an object: public class Puppy public Puppy(String name){ // This constructor has one parameter, name. System.out.println("Passed Name is :" + name); } public static void main(String [args) { // Following statement would create an object myPuppy Puppy myPuppy = new Puppy( "tommy"); If we compile and run the above program, then it will produce the following result: Passed Name is :tom
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
