lec1 Flashcards
(34 cards)
What is a computer program?
A set of instructions that tells a computer what to do.
Why do computers need programs?
Without programs, computers are just empty machines.
What is Java?
A popular programming language created in 1995 and owned by Oracle.
Where is Java used?
Mobile apps, web apps, desktop apps, games, databases, and more.
Why is Java popular?
it is platform-independent, secure, fast, and object-oriented.
What does “Write Once, Run Anywhere” (WORA) mean?
Java code can run on any device with a Java Virtual Machine (JVM).
What is source code?
The code written by a programmer before it is compiled or interpreted.
What does an interpreter do?
Reads and executes code line by line.
What does a compiler do?
Translates the entire source code into machine code before execution.
Does Java use an interpreter or a compiler?
Java uses both: the compiler converts code into bytecode, and the JVM interprets it.
Where can you download Java?
From oracle.com.
What are two popular Java IDEs?
Eclipse and NetBeans.
What must every Java program have?
At least one class.
What is the name of the method where Java starts execution?
The main method.
What is the correct syntax for the main method?
public static void main(String[] args) { }
What does System.out.println(“Hello”); do?
Prints “Hello” to the console.
How do you write a simple Java program?
public class Hello {
public static void main(String[] args) {
System.out.println(“Hello, Java!”);
}
}
What is a statement in Java?
A command that performs an action, like printing text.
Why is documentation important in Java?
t makes code easier to understand and maintain.
What are good naming conventions for Java?
Classes: Start with uppercase (ComputeExpression).
Variables/methods: Start with lowercase (computeSum).
How should Java code be formatted?
Use indentation and blank lines for readability.
What are the three types of errors in Java?
Syntax errors – Found by the compiler.
Runtime errors – Cause the program to crash.
Logic errors – Produce incorrect output.
What is a runtime error?
An error that happens while the program is running.
What is an object-oriented language?
A language that organizes code using objects and classes.