M2 Flashcards
defines a class, a
template for an object of derived type
HelloWorld
class HelloWorld –
access specifier/modifier,
public –
the main
method is declared private so that it is
accessible as part of the public interface of
the program.
false public
state of the method
static –
void – It returns void because the Java
interpreter X.
does not expect to receive or
process any output from the class
The X class is a part of the core Java language package of the Application Programming Interface (API)
System
The X method
is one of dozens of methods in the System
class.
println
JAVA LANGUAGE FUNDAMENTALS
ØIdentifiers
ØKeywords
ØComments
ØData types
X are names that are given by the
programmer as name of variables, methods
or functions, classes etc.
Identifiers
Java Comments are of three (3) types:
Java Comments are of three (3) types:
1. A single-line comment starting with //
2. A multi-line comment enclosed within /* */
3. A documentation or javadoc comment is
enclosed between /** and */
byte, short, int, long, float, double, boolean, char are
primitive data types
variable declaration syntax
; [= value;]
assigning a value to a variable syntax
= value;
X are used in
converting one data type (such as a
String) into another data type (such as
int or double).
Java Wrapper Classes
used in
wrapping a primitive value into an
object
Java Wrapper Classes
here:
System.out.print();
X is a public static field: it accepts output data
out
here:
System.out.print();
X is a class
System
It prints string inside the quotes
print() -
It prints string inside the quotes similar like print() method. Then the cursor moves to the beginning of the next line
println() -
It provides string formatting (similar to printf in
C/C++ programming).
printf() -
used to restrict the output depending on the conversion. It specifies the number of digits of precision when outputting floating-point values or the length of a subtracting to extract from a string. Numbers are rounded to the specified precision.
printf() -
The X class is used to get user input, and it is found in the java.util package.
Scanner