Basic Java Definitions and Syntax Rules
String combination identifier
"+"
What must every line of code not followed by curly braces end in?
";"
How do you assign data to a variable?
"=". ex. int number = 100
How to use sub-string function?
...
Reasons to use "double"
1023 digits after the decimal point
Reasons to use "float"
127 digits after the decimal point
What must a class name always start with?
A capital letter then camel case with no spaces.
.java
All Java file names have to have this extension.
Capital Letter
All java file names must have this at the beginning.
Methods?
Are always public. They return data. Methods are made so that you can call on them so that you can use its functionality.
Naming Methods?
Begins with public then is whatever data is going to be returned. ex. public String displayname()
Surround all String text with?
Double Quotes
What is camel casing?
Each time a new word begins start it with a capital letter
What must variable names have/not have?
Have: Starts with a lower case letter. Not Have: after initial letter cannot have a symbol other than the underscore (no spaces).
Define how java classes are connected.
Loosely connected objects that interact with each other.
Reasons to use "int"
Numbers -2 billion to, 2 billion
Reasons to use "long"
Numbers greater then ±2 billion
4 Java Data Types?
Numeric, String, Character, Boolean.
Define the Java related "object" and what is it interchangeable with?
Object and class define state (data_ and behavior (operations). Classes define an object's behavior.
Private variable declaration?
Only applies to that class. ex. private String first;
return function?
Returns and expression. ex. return first + " " + middle + " " + last;
How to declare variables with the same data type on the same line?
Separate them with commas. ex. int number, salary, hoursWorked; (end with semi-colon)
What non-numeric data type can have class operations preformed to it?
String
What word is always capitalized in java syntax?
String
0 or more characters surrounded by double quotes?
String (always capital "S")
Example of variable declaration and explanation.
String firstName; Start with data type then variable name. Must end with the ";".
Set of print commands to print to the console on two different lines?
System.out.print("Hello"); //no "ln" System.out.print("World"); //Has the "ln"
Command to print to the console? (what letter is capitalized)
System.out.println("Hello");
What does empty Parenthesis at the end of a method declaration mean?
That the data for the method will be put in later.
True False data type
boolean
Alphabetic characters that can be stored as a numeric value?
char
For numeric data types what declaration will always be used?
double
Insert a comment? On multiple lines?
double slash ex. //commented slash asterisk ex. /* one line two lines */ (its the back slash for both)
Numeric Data Sub-Types
int, long, float, double
What could a object be compared to for similarity?
like base blocks that are interchangeable in how they can be used in other programs.
How to define a class?
public class "class name" (no extension)
Standard Starting, to start code block?
public static void main(String[] args) { //code goes here }