12.6k views
5 votes
A comment on more than one line needs what characters placed where in order to be ignored by the program?

forward slash and star at the beginning of the comment and a star and foward slash at the end
two forward slashes following the comment
two forward slashes at the beginning of the comment
forward slash and star at the beginning of the comment

User Mrhellmann
by
4.4k points

2 Answers

3 votes

The correct answer is "forward slash and star at the beginning of the comment and a star and foward slash at the end ".

User Freddygv
by
4.5k points
2 votes

Answer: Forward slash and star at the beginning of the comment and a star and forward slash at the end. (/* This is a comment */)

The best explanation of this would be:

1 // This is a comment

2 System.out.print("Good Job");

This type of comment where two forward slashes at the beginning make everything that is written on the line a comment.

1 System.out.print("Good Job"); //This line will print Good Job.

2 System.out.print("Terrific"); //This line will print Terrific.

This type of comment is generally used when you would want to keep track of what a certain line of code will do.

1 /*

2 System.out.print("Good Job");

3 System.out.print("Terrific");

This type of comment will make everything starting from line 1 into a comment and not execute the rest as code.

1 /*

2 System.out.print("Good Job");

3 System.out.print("Terrific"); */

4 System.out.print("Magnificent");

This type of comment will turn lines 1, 2, and 3 into comments and will execute only the code in line 4.

User Madteapot
by
5.1k points