Syntax Flashcards
Learn about Java syntax (grammar)
What is a semicolon ( ; ) used for?
To end a Statement.
What are curly braces/brackets for? ( { } )
They are for grouping blocks of code, whether it’s a part of a class, method, or conditional statement.
What should every Java source code file (generally) start with?
Defining a class. Ex. public class ClassName
What does // mean?
A single line comment. The compiler ignores this line.
What does /* */ represent?
A block comment, it is used to comment out a block of code. It can also be used on a single line.
What method should (generally) be present in a Java program?
The ‘main’ method. This is the entry point into the program.
Ex. public static void main(String[] args)
What should always come in pairs?
Parentheses, braces and quotation marks.
( ) [ ] { } “ “ ‘ ‘
How is whitespace treated by the compiler?
It is ignored. Unless it is within two double quotation marks.