MIDTERM Flashcards
Java is a ____-level, ______-oriented programming language
high-level and object-oriented
Java is designed to be
1. S
2. P
3. E
Simple, Portable, and Efficient
Java uses ___-built components to enhance efficiency
pre-built components
What is the meaning of WORA?
Write Once, Run Anywhere
What can Java do? It is a _______-purpose language.
General-purpose language used for
- Web applications
- Mobile applications
- Desktop software
Why use Java?
1. R
2. S
3. S
Robust, Secure, and Simple
Java is _____-based promoting code ___________.
Code-based promoting Code Reusability
Java runs in a secure environment. It converts bytecode into machine code.
Java Virtual Machine
Faster than other languages due to JIT compiler. Meaning of JIT?
Just-In-Time compiler
Where is Java code compiled into?
bytecode
What is a small Java program embedded in a web page?
Java Applet
What is a Java Application?
Full-fledge java program that runs on an operating system
Java Application requires this to execute. It provides libraries and JVM to run Java Programs
Java Runtime Environment
A software development kit used to develop Java applications
Java Development Kit
A rich set of built-in libraries supporting file handline, network, etc.
Java Class Libraries / APIs
it defines the rules for writing Java programs
Syntax
Every Java statement must be within a ____, which starts with an uppercase letter.
Class
Every statement in Java must conclude with a _________.
Semicolon (;)
It defines a class named Main
public class Main
The main method where execution starts
public static void main (String[] args)
Prints output to the console
System.out.println(“Hello, Java!”);
[TYPES OF COMMENTS]
Used for short explanations
Single-line comments (//)
[TYPES OF COMMENTS]
Use for longer descriptions
Multi-line comments (/* … */)
[TYPES OF COMMENTS]
Use for generating documentation
Javadoc comments (/** … */)
These are names given to variables, methods, classes, etc.
Java Identifiers
[TRUE OR FALSE]
Is Java case-sensitive?
True
[TRUE OR FALSE]
Identifiers must not begin with a letter, $, or _ (not a number).
False. It MUST begin with a letter, $, or _
[TRUE OR FALSE]
Identifiers cannot be a Java keyword.
True
What are reserved words that have special meanings in Java?
Java Keywords
[TRUE OR FALSE]
Java Keywords can be used as identifiers.
False. It CANNOT be used as identifiers.
What are constant values assigned to variables directly in a code?
Java Literals
[TRUE OR FALSE]
Java literals remain unchanged during program execution.
True
[TYPES OF JAVA LITERALS]
Whole number belonging to the int data type
Integral Literals
[TYPES OF JAVA LITERALS]
Represents decimal numbers.
Floating-Point Literals
[TYPES OF JAVA LITERALS]
Only True or False
Boolean Literals
[TYPES OF JAVA LITERALS]
Represents a single character.
Character Literals
[TYPES OF JAVA LITERALS]
Represent a sequence of characters.
String Literals
[TYPES OF INTEGRAL LITERALS]
Uses digits 0-9, no prefix.
Decimal (Base-10)
[TYPES OF INTEGRAL LITERALS]
Uses digits 0-7, prefixed with 0.
Octal (Base-8)
[TYPES OF INTEGRAL LITERALS]
Uses digits 0-9 and A-F, prefixed with 0x.
Hexadecimal (Base-16)
[TYPES OF INTEGRAL LITERALS]
Uses only 0 and 1, prefixed with 0b.
Binary (Base-2)
[TYPES OF FLOATING-POINT LITERALS]
The default type for decimals. Offers about 15-16 digits of precision. High precision but uses more memory.
Double
[TYPES OF FLOATING-POINT LITERALS]
Less precision but uses less memory. Offers about 7 digits of precision. Requires f or F suffix.
Float
[TRUE OR FALSE]
Java does accept 0 or 1 as boolean values.
False. Java DOES NOT accept 0 or 1 as boolean values
[TRUE OR FALSE]
Character literals are enclosed in double quotes (“ “).
False. It is enclosed in single quotes (‘ ‘) only.
[TRUE OR FALSE]
Character literals supports escape sequences (e.g. \n, \t, \, etc.)
True
[TRUE OR FALSE]
String literals are enclosed in single quotes (‘ ‘).
False. It is enclosed in double quotation (“ “)
[TYPES OF DATA TYPES]
Fundamental types that cannot be broken down further.
Primitive Data Types
[TYPES OF DATA TYPES]
Reference data types that store memory addresses.
Non-primitive data types
These stores data that can be manipulated throughout a program.
Variables
It defines the TYPE of data stored. (e.g. int, String, float, etc.)
Data Type
It identifies the variable. What the variable is called.
Variable name
The assigned data in a variable
Value
[TYPES OF VARIABLES]
Declared inside a method; only accessible within that method
Local Variable
[TYPES OF VARIABLES]
Declared within a class but outside methods; unique to each instance.
Instance Variable
[TYPES OF VARIABLES]
Declared with the static keyword; shared among all instances.
Static Variable
These are values that do not change during program execution.
Constants
What keyword must be used to declare constants?
final
Difference between Variables and Constants?
Variable: values CAN change
Constant: values CANNOT change after initializatio
What are symbols used to perform operations on variables and values.
Java Operators
[TYPES OF JAVA OPERATORS]
It performs mathematical calculations (addition, subtraction, etc.)
Arithmetic Operators
[TYPES OF JAVA OPERATORS]
Used to compare values (Equal to, not equal to, etc.)
Relational Operators
[TYPES OF JAVA OPERATORS]
Used for boolean logic (AND, OR, NOT)
Logical Operators
AND (&&)
OR (!!)
NOT (!)
[TYPES OF JAVA OPERATORS]
Used to assign values to variables (assign, add and assign, subtract and assign, etc.)
Assignment Operators
[TYPES OF JAVA OPERATORS]
Used to operate on a single operand (increment, decrement, invert)
Unary Operators
[TYPES OF JAVA OPERATORS]
Used to shift bit positions (left shift, right shift, etc.)
Shift Operators
[TYPES OF JAVA OPERATORS]
Shorthand for if-else statements.
Ternary Operator
A combination of variables, operators, and method invocations that evaluate to a single value.
Java Expressions
It determines the order in which operators are evaluated in an expression.
Operator Precedence