Chapter 2 Flashcards
What is a constructor in java
this is a special type of method that creates a new object based on the parent Class.
What is the correct syntax of a constructor within in a class
public name () { }
What does a normal method have that a constructor does not have
A return type
What do we know of the name of a constructor class
The name matches the name of the parent class.
what is between the braces in java { }
a Code block
Name four types of code blocks
A Class definition
A Method declaration
A Inner Block
A instance initializer
What is the correct order of initialization in a class in regards to running the code
Fields and instance initializer first in order of appearnce in the code (top to bot) Followed by the constructor.
is a “String” variable a primitive type?
No, A string is a object, not a primitive type.
What are correct values for a boolean
True or False
What is the correct value range for a byte
-128 to 127
what is the difference between a int and a float
The same range as the fields of a int, but with up to 7 decimal digits
what is the difference between a long and a double
The same range as the fields of a long, but with up to 16 decimal digits
what do all possible values of the ‘char’ type have in commen.
They are all members of the Unicode Ascii values
What is a easy way to calculate the total range of a “byte”
A byte is 8 bits. A bit can have 2 values : 1 or 0. So a byte can have a range of 2^8 different combinations of bits.
How are the maximum number of bits used by the Java engine.
Java uses the bits to figure out how much memeory is needed for a Var. For example Java allocates 32 bits if you write (int num;) Memory is wasted if the value of num never exceeds a “short” wich is halve the size.
What happens when we you declare a value that fits a long and does not fit a int. But without including a capitol L at the end of the value.
java will throw a error because any number in java code is considered a int if not declared as a long by adding the L like : 3123456789L