click below
click below
Normal Size Small Size show me how
SCJA-drills-chap04
Question | Answer |
---|---|
What are primitives? | Primitives are the fundamental data type in Java. |
What is an int? | int is a primitive data type that is used to store integer values. |
What is a float? | float is a primitive data type that is used to store floating-point values. |
What is a boolean? | boolean is a primitive data type that is used to store true or false values. |
What is a char? | char is a primitive data type that is used to store a single Unicode character. |
What are the conventions regarding primitive versus class names? | Primitive data types all start with a lowercase letter, while classes start with a capital letter. |
What are the wrapper classes for each primitive? | Each primitive data type has a corresponding wrapper class: Integer, Float, Boolean, and Character. Note the capital letters. |
What are objects in relation to primitives? | Objects are more advanced data types. They may be defined by a developer or found in a built-in Java package. |
How are objects initialized? | Objects must be initialized by using the new keyword. |
What is the use of the 'new' keyword? | Objects must be initialized by using the new keyword. |
Define arrays and the way they are used. | Arrays are objects and allow you to store multiple variables together that can be accessed by an index. |
What are enumerations? Compare enumeration and variable usage. | Enumerations are special objects that allow a developer to create a predefined set of constants. A variable can then be set to only one of the predefined values. |
Complete the sentence and explain what is means: Java is a _______ (hint: weight) typed language. | Java is a strongly typed language. Variables must be declared as a type, and any value that is stored must be compatible with this type. |
What is cast and what happens if it is not properly used? | It is possible to cast a variable to a different data type. If incompatible types are cast, an exception will be thrown. |
What is a literal? | A literal is a value that is hardcoded in code as the value itself. |
What are the Java naming conventions regarding classes? | Java naming conventions dictate that a class should be named with the first letter capitalized, along with each sequential word in the name. |
What are the Java naming conventions regarding variables? | Java naming conventions dictate that a variable should be named with the first letter being lowercase, and with each sequential word in the name beginning with a capital. |