Class → main() → statements
📌 Java data types have two main categories: primitive data types, such as int, double, char, and boolean, and reference data types, which include arrays, classes, and interfaces.
Primitive values versus reference objects
★ Must-know
The int type is generally the default type for integral values unless memory space is a concern, while long is used when a wider range than int is needed.
The double type is generally the default type for decimal values, while float is also used to save memory in large arrays of floating-point numbers.
Further detail
📌 The syntax for a named constant is final data_type variable_name = value, and a named constant can be assigned a value only once.
Variable changes; constant stays fixed
★ Must-know
📌 Widening conversion changes a lower-precision data type to a higher-precision type, is performed implicitly by the JVM, and causes no loss of information.
📌 Narrowing conversion changes a higher-precision data type to a lower-precision type and typically involves loss of information, so the programmer must use an explicit cast.
Further detail
The explicit cast operator has the form , where the expression is evaluated first and its value is then treated as the specified type.
Casting the float value 6.82f to int with int a = (int) x; produces the integer value 6.
Widening preserves information; narrowing may lose it
Sequential execution versus altered flow
★ Must-know
Further detail
Test your knowledge on Java Programming Basics with 11 multiple-choice questions with detailed corrections.
1. What is the basic unit in which Java code is grouped?
2. What is the primary purpose of the main() method in a Java program?
Memorize the key concepts of Java Programming Basics with 11 interactive flashcards.
What is Java in programming?
Java is a high-level, object-oriented programming language.
Java Program Structure
Class with main() method as entry point.
What is the basic unit of a Java program?
A class is the basic unit of a Java program.
Import your course and AI generates sheets, quizzes and flashcards in 30 seconds.
Sheet generator