Untitled Document
Untitled Document
Class: A blueprint for creating objects, defining properties (fields) and behaviors (methods).
Method: A block of code inside a class that performs an action or computes a value.
Properties: Also called fields or attributes, these store the state/data of an object.
Object: An instance of a class, representing a specific entity with behavior and state.
Encapsulation
Inheritance
Polymorphism
Abstraction
---
QUESTION 2
if statement:
if (a > b) {
System.out.println("a is greater");
}
if...else statement:
if (a > b) {
System.out.println("a is greater");
} else {
System.out.println("b is greater");
}
System.out.println("Hello\tWorld\nNew Line");
---
QUESTION 3
import java.util.Scanner;
b) Statement explanations:
---
QUESTION 4
import java.util.Scanner;
double discriminant = b * b - 4 * a * c;
double root1 = (-b + Math.sqrt(discriminant)) / (2 * a);
double root2 = (-b - Math.sqrt(discriminant)) / (2 * a);
---
QUESTION 5
import java.util.Scanner;
Multi-line:
/* This is a
multi-line comment */
c) Use of ; in Java:
The semicolon ; marks the end of a statement in Java.
---
QUESTION 6
import java.util.Scanner;
---
QUESTION 7
a) Java Applet:
A Java applet is a small program that runs in a web browser and is embedded in an HTML
page.