java 1

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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

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.println( "Turing, Alan" );

The open curly brace begins a class.

The class body is placed within curly braces. Best practice is to include comments describing what the code accomplishes. Every coding team working on the program should create, update, and/or modify documentation as needed. The closed curly brace ends a class.

The class header marks the beginning of the class definition and contains the class name.

The class header marks the beginning of the class definition and contains the class name.

/*This is a multi-line * comment. It also can be referred to as a comment box. * Multi-line comments start with a forward slash and an asterisk * and end with an asterisk and a forward slash. * The complier ignores everything between those symbols. */

/*This is a multi-line * comment. It also can be referred to as a comment box. * Multi-line comments start with a forward slash and an asterisk * and end with an asterisk and a forward slash. * The complier ignores everything between those symbols. */

//This is a single-line comment

//It begins with two forward slashes. //The compiler ignores everything from that point to the end of the line.

/** * This is a Javadoc comment example. * It also can be referred to as a Javadoc comment box. * Any comment that starts with a forward slash and two asterisks * and ends with an asterisk and a forward slash is considered a documentation * comment. * The purpose of the Javadoc comment is to * enable the Javadoc utility to * generate attractively formatted HTML files * that document the source code according to what * is written between the /** and */. HTML tags * and Javadoc tags are used in the documentation to * highlight important code. */

/** * This is a Javadoc comment example. * It also can be referred to as a Javadoc comment box. * Any comment that starts with a forward slash and two asterisks * and ends with an asterisk and a forward slash is considered a documentation * comment. * The purpose of the Javadoc comment is to * enable the Javadoc utility to * generate attractively formatted HTML files * that document the source code according to what * is written between the /** and */. HTML tags * and Javadoc tags are used in the documentation to * highlight important code. */

The first comment box should contain the Java file name, the author's name, the version number with date and time, and the purpose of the program. It should be a Javadoc comment. Begins with /** Ends with */

2.1 slide 18

rearrange the following code so that it forms a correct program that prints out the letter Q

From: } public static void main(String[] a) { } System.out.println("Q"); public class Q { To: public class Q { public static void main(String[] a) { System.out.println("Q"); } }

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" ); System.exit( 0 ); } }

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" ); System.exit( 0 ); }

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

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

The method header marks the beginning of the method, which is a group of programming statements that have a name. public static void main(String[] args) In this case, the name is main.

side 22

The method header marks the beginning of the method, which is a group of programming statements that have a name. In this case, the name is main. The next open curly brace begins a method. The method line comments declare methods or local variables. Any code within the curly braces belongs in that method. The individual programmer determines all the comments. The closed curly brace ends a method.

slide 17 2.1

A block of code consists of the statements contained in a pair of curly braces. A block is a compound statement and includes all statements between an opening and a closing curly braces

slide 52 2.1


संबंधित स्टडी सेट्स

Convection, Conduction and Radiation Examples + Definitions

View Set

business management chapter 9-1 and 9-2

View Set

MU 3100 Final Exam 2021 - HB Quizlet PDF

View Set

Chapter 16 Fluid and Electrolytes Practice Questions

View Set

CHP 12 - Motivation Across Cultures

View Set

Chapter 3: Health, Wellness, and Health Disparities

View Set

Academic Decathlon - Economics (2020)

View Set