🎯 GRADE 10 JAVA PRACTICAL MASTER STUDY GUIDE – AIMING
FOR 100%
🔹 1. Introduction to Java Programming
🧠 Theory: Basic Java Structure
Every Java program follows this basic structure:
java
public class ClassName {
public static void main(String[] args) {
// Your code goes here
[Link]("Hello World!");
}
}
✅ Key Points:
Every program needs a main method
Use [Link]() for output
Use Scanner for input
End statements with semicolons ( ; )
Use curly braces {} to group code
🧪 Example: Complete Program Structure
java
import [Link];
public class MyProgram {
public static void main(String[] args) {
Scanner input = new Scanner([Link]);
[Link]("Enter your name: ");
String name = [Link]();
[Link]("Hello " + name + "!");
}
}
🔹 2. Integer and Real Numbers
🧠 Theory: Data Types
int: Whole numbers (-2,147,483,648 to 2,147,483,647)
double: Decimal numbers (15-17 decimal digits precision)
✅ Type Casting Rules
java
int a = 5;
int b = 2;
int result1 = a / b; // Result: 2 (integer division!)
double result2 = (double)a / b; // Result: 2.5 (proper division)
// Converting double to int
double x = 3.7;
int y = (int)x; // y = 3 (truncates decimal)
🎯 Exam Tip: Integer Division Warning
5 / 2 = 2 (NOT 2.5!)
To get 2.5, use: 5.0 / 2 or (double)5 / 2
🔹 3. Characters, Strings & Math Class
🧠 String Methods (MEMORIZE THESE!)
java
String text = "Hello World";
[Link]() // Returns: 11
[Link](0) // Returns: 'H'
[Link](0, 5) // Returns: "Hello"
[Link]() // Returns: "HELLO WORLD"
[Link]() // Returns: "hello world"
[Link]("Hello World") // Returns: true
🧠 Character and Unicode
java
char letter = 'A';
int ascii = (int)letter; // ASCII value of 'A' is 65
char fromAscii = (char)65; // Converts 65 back to 'A'
🧠 Math Class Methods
java
[Link](16) // Returns: 4.0
[Link](2, 3) // Returns: 8.0 (2³)
[Link](-5) // Returns: 5
[Link](3.7) // Returns: 4
[Link]() // Returns: random number 0.0 to 0.999...
// Random number between 1 and 6 (dice):
int dice = (int)([Link]() * 6) + 1;
🎯 Rounding to 2 Decimal Places
java
double number = 3.14159;
double rounded = [Link](number * 100.0) / 100.0;
// Result: 3.14
🔹 4. Problem Solving using Computational Thinking
🧠 IPO Model: Input → Process → Output
Example Problem: Calculate area of circle
Input: radius
Process: area = π × radius²
Output: display area
🧠 5 Key Concepts:
1. Decomposition: Breaking big problems into smaller parts
2. Abstraction: Focusing on important details, ignoring unnecessary ones
3. Pattern Recognition: Finding similarities between problems
4. Algorithm: Step-by-step instructions to solve problem
5. Evaluation: Testing if solution works correctly
🧪 IPO Example:
java
// INPUT
Scanner input = new Scanner([Link]);
[Link]("Enter radius: ");
double radius = [Link]();
// PROCESS
double area = [Link] * [Link](radius, 2);
// OUTPUT
[Link]("Area = " + area);
🔹 5. FOR Loops
🧠 Forward Loop
java
for (int i = 1; i <= 5; i++) {
[Link]("Number: " + i);
}
// Output: 1, 2, 3, 4, 5
🧠 Backward Loop
java
for (int i = 5; i >= 1; i--) {
[Link]("Number: " + i);
}
// Output: 5, 4, 3, 2, 1
🧪 Gogga Loop Example
java
Gogga bug = new Gogga();
for (int i = 1; i <= 4; i++) {
[Link](50);
[Link]();
}
// Draws a square!
🔹 6. Objects (Gogga)
🧠 What is an Object?
An object is like a robot that has:
State: Current position, color, direction
Behavior: Actions it can perform (methods)
🧠 Creating Gogga Objects
java
Gogga bug1 = new Gogga(); // Default constructor
Gogga bug2 = new Gogga(100, 150); // Constructor with position
🧠 Essential Gogga Methods
java
[Link](x, y); // Move to specific coordinates
[Link]([Link]); // Change color
[Link](distance); // Move forward
[Link](); // Turn 90° left
[Link](); // Turn 90° right (turnLeft 3 times)
🧪 Drawing Patterns
java
// Square
for (int i = 0; i < 4; i++) {
[Link](100);
[Link]();
}
// Triangle
for (int i = 0; i < 3; i++) {
[Link](100);
[Link]();
[Link]();
[Link]();
[Link]();
[Link](); // 5 left turns = 450° = 90° right turn
}
🔹 7. IF Statements
🧠 Basic IF
java
if (age >= 18) {
[Link]("You can vote!");
}
🧠 IF-ELSE
java
if (mark >= 50) {
[Link]("Pass");
} else {
[Link]("Fail");
}
🧠 ELSE-IF Ladder
java
if (mark >= 80) {
[Link]("A");
} else if (mark >= 70) {
[Link]("B");
} else if (mark >= 60) {
[Link]("C");
} else {
[Link]("F");
}
🧠 Comparison Operators
== Equal to
!= Not equal to
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
🔹 8. Bonus Review
📊 Math Functions Quick Reference
Function Purpose Example
[Link](x) Square root [Link](25) → 5.0
[Link](x,y) x to power y [Link](2,3) → 8.0
[Link](x) Absolute value [Link](-7) → 7
[Link](x) Round to nearest [Link](3.7) → 4
[Link]() Random 0-1 [Link]() → 0.234...
📊 String Methods Quick Reference
Method Purpose Example
.length() Get length "Hello".length() →5
.charAt(i) Get character at position "Hello".charAt(1) → 'e'
.substring(start,end) Extract part "Hello".substring(1,4) → "ell"
.toUpperCase() Convert to uppercase "hello".toUpperCase() → "HELLO"
.equals(other) Compare strings "hi".equals("hi") → true
🎯 Common Gogga Patterns
java
// Square
for (int i = 0; i < 4; i++) {
[Link](size);
[Link]();
}
// Line of squares
for (int i = 0; i < 3; i++) {
// Draw square
for (int j = 0; j < 4; j++) {
[Link](50);
[Link]();
}
[Link](100); // Move to next position
}
🎯 FINAL EXAM STRATEGY
✅ Program 1: Variables, Input, Calculations, Output
Template to follow:
java
import [Link];
public class Program1 {
public static void main(String[] args) {
Scanner input = new Scanner([Link]);
// INPUT - Get data from user
[Link]("Enter [description]: ");
[datatype] [variable] = input.[next___]();
// PROCESS - Do calculations
[datatype] result = [calculation];
// OUTPUT - Display results
[Link]("[description]: " + result);
}
}
✅ Program 2: Gogga Drawing
Template to follow:
java
import [Link];
public class Program2 {
public static void main(String[] args) {
Gogga bug = new Gogga();
// Set starting position and color
[Link](x, y);
[Link](Color.[COLOR]);
// Draw your pattern using loops
for (int i = 0; i < [number]; i++) {
[Link]([distance]);
[Link](); // or multiple turnLeft()s
}
}
}
🏆 LAST-MINUTE CHECKLIST
✅ Remember semicolons ( ; ) after every statement ✅ Use proper capitalization: Scanner ,
[Link] ✅ Import statements: import [Link]; ✅ Gogga colors:
[Link] , [Link] , etc. ✅ For integer division, cast to double: (double)a / b ✅ String
comparison: use .equals() , not == ✅ Test your loops: count iterations carefully ✅ Check
parentheses and braces match: () and {}
🎯 YOU'VE GOT THIS! GO GET THAT 100%!
Good luck on your exam tomorrow! You're well-prepared! 🌟