Java anatomy Flashcards
What is this part called in a Java program…
class HelloWorld {
. . . .
}
Class definition
What is this part of a Java program called…
public static void main(String[ ] args) {
. . . .
}
Main method
What type of java statement is this…
System.out.println(“Goodnight”);
Print statement
What type of Java statement is this…
int myInteger;
Variable declaration (for creating variables)
What type of Java statement is this…
myInteger = 65 + 6;
Assignment statement
What type of Java statement is this…
Import Java.util.Scanner;
Import statement
What is this part of a Java program…
public class Simple
{
public static void main(String[] args) <–
}
}
Method body
What are parentheses used for in a Java program…
()
They are used in a method header
What are braces used for in a Java program…
{
}
They are used to enclose a group of statements ie. content of a class or a method header.
In this context…
System.out.println(“Juneid Akoutam”);
The … class holds the … object, which is a member of the … class and the … method is a member of the … object.
System, out, System, println, out
Class= System
Object = out
Method = println
What does this escape sequence do:
\b
Causes the cursor to back or, or move left one position
What will the following statement print out…
System.out.println(“Hello my name is Juneid \rcock”);
Cock
What will the following statement print out:
System.out.println(“Hello my name is Juneid\b\b\bcock”);
Hello my name is Juncock
What is the purpose of the following escape sequence do:
'
Causes a singe quotation mark to be printed
What is the purpose of the following escape sequence
"
Causes a double quote mark to be printed
What is a variable
A named storage location in the computer’s memory
What is a literal
A value that is written into the code of a program, it is a fixed value
ex:boolean
True or false the first character of an identifier can be a digit
False
True of false the first item of an identifier can be an underscore
True
True or false an identifier can contain a space
False
How many bytes does a short contain
2
How many bytes do ints and floats contain
4
How many bytes do doubles and longs contain
8
True or false char literals are enclosed in single quote marks ex ‘a’
True