COMP 1510 CH2
What is a string literal?
A string literal is a sequence of characters delimited by double quotes.
What is a character set?
A character set is a list of characters in a particular order. A character set defines the valid characters that a particular type of computer or programming language will support. Java uses the Unicode character set.
What is a nu l 7 reference?
A null reference is a reference that does not refer to any object. The reserved word nu l l can be used to check for null references before following them
What type does Java automatically assign to a floating point literal? How can you indicate that a floating point literal should be considered a different type?
Java automatically assigns a floating point literal the data type double. If you append an F or an f on the end of a floating point literal, for example 12 . 34f, Java will assign it the type fl oat.
What type does Java automatically assign to an integer literal? How can you indicate that an integer literal should be considered a different type?
Java automatically assigns an integer literal the data type int. If you append an Lor an 1 on the end of an integer literal, for example 1234L, Java will assign it the type long
What are the four integer data types in Java? How are they different?
The four integer data types in Java are byte, short, int, and long. They differ in how much memory space is allocated for each and therefore how large a number they can hold.
What is an alias? How does it relate to garbage collection?
Two references are aliases of each other if they refer to the same object. Changing the state of the object through one reference changes it for the other because there is actually only one object. An object is marked for h garbage collection only when there are no valid references to it.
pass meaning
passing variable in a function or something else
Write a code statement that sets the value of an integer variable called size to the length of a String object called name.
size= name . length() ;
What is an escape sequence? Give some examples.
An escape sequence is a series of characters that begins with the backslash,(\) and that implies that the following characters should be treated i some special way. Examples: \n represents the newline character, \ t represents the tab character, and \ " represents the quotation character (as opposed to using it to terminate a string).
What is operator precedence?
Operator precedence is the set of rules that dictates the order in which operators are evaluated in an expression
What does the new operator accomplish?
The new operator creates a new instance (an object) of the specified class. The constructor of the class is then invoked to help set up the newly created object.
How many characters are supported by the ASCII character set, the extended ASCII character set, and the Unicode character set?
The original ASCII character set supports 2^7 = 128 characters, the extended ASCII character set supports 2^8 = 256 characters, and the UNICODE character set supports 2^16 = 65,536 characters.
call meaning
invoke a function ex) (in the main method) myFunction()
Why are widening conversions safer than narrowing conversions?
A widening conversion tends to go from a small data value, in terms of the amount of space used to store it, to a larger one. A narrowing conversion does the opposite. Information is more likely to be lost in a narrowing conversion, which is why narrowing conversions are considered to be less safe than widening ones. SR
Identify each of the following conversions as either a widening conversion or a narrowing conversion a. int to 1ong b. int to byte c. byte to short d. byte to char e. short to double
The conversions are: a. widening, b. narrowing, c. widening, d. widening, e. widening.