Sunday, June 10, 2012

Java Codelab: 1.1 Your first program

Java Codelab

1.1 Your first program

Write a statement that prints  Hello, world to the screen.

System.out.println("Hello, world");


 Write a complete main  method that prints  Hello, world to the screen.  

public static void main(String[]args){
System.out.println("Hello, world");
}

 Suppose your name was Alan Turing. Write a statement that would print your last name, followed by a comma, followed by a space and your first name.  

System.out.print("Turing, Alan");

Suppose your name was George Gershwin. Write a complete main method that would print your last name, followed by a comma, followed by a space and your first name. 

public static void main(String[]args){
System.out.println("Gershwin, George");
}

Write a complete program whose class name is Hello and that displays  Hello, world on the screen.

public class Hello {
public static void main(String[]args){
System.out.println("Hello, world");
}
}




No comments:

Post a Comment