Java Intro Flashcards
What is Java?
A high-level, object-oriented programming language designed for minimal implementation dependencies.
What is a key feature of Java that allows it to run on any device?
Platform-Independent: Runs on any device with Java Virtual Machine (JVM).
What does object-oriented mean in the context of Java?
Uses classes and objects to model real-world entities.
What is the basic structure of a Java program?
Arrangement of components including class declaration, main method, and statements.
What is the purpose of ‘public class Main’ in a Java program?
Declares the class. Every program must have at least one class.
What is the entry point of a Java program?
public static void main(String[] args)
What does System.out.println() do in Java?
Prints text to the console.
What is a variable in Java?
Stores changeable data during execution.
What are primitive data types in Java?
Types that define the kind of data, such as:
* int
* double
* char
* boolean
What is an example of a reference data type in Java?
String: Sequence of characters (e.g., ‘Hello, World!’)
What is the difference between declaration and initialization of variables?
Declaration specifies the type and name; initialization assigns a value.
Fill in the blank: To declare an integer variable in Java, use ______.
int x;
What are operators in Java?
Symbols or keywords used to perform operations on variables/values.
List the types of operators in Java.
- Arithmetic Operators
- Comparison Operators
- Logical Operators
What is the purpose of comments in Java?
Non-executable lines for explaining code.
What are the two types of comments in Java?
- Single-line: // Comment
- Multi-line: /* Comment */
What is code formatting best practice in Java?
Structuring code for readability and consistency.
What is recommended for variable names in Java?
Camel Case (e.g., myVariable)
True or False: Java syntax is strict but logical.
True
What is the role of variables, data types, and operators in Java?
Essential for data manipulation.
How does code formatting and commenting affect Java code?
Improves readability and maintenance.
What is the output of the following code: int a = 10; int b = 20; System.out.println(a + b);?
30
What does the % operator do in Java?
Returns the remainder of division.
Fill in the blank: A non-primitive data type in Java is ______.
String