Thursday, October 8, 2026

Java Programming Notes - Class 2: Control Flow, Methods & OOP CSC102S3 Course Title: Computer Programming I Online Class English and Tamil Medium

☕ Java Programming – Class 2 Notes

Control Flow • Methods • OOP Fundamentals • Problem Solving Exercises

Selection (if/switch) Loops (for/while) Methods Classes & Objects Mini Project
🔀 Part A – Selection Statements (Making Decisions) ▼

Normally Java runs statements top-to-bottom (sequence). Selection statements change that order by checking a boolean condition (true/false).

A.1 The if Statement

Runs a block only when the condition is true.

int age = 20; if (age >= 18) { System.out.println("You are eligible to vote."); } System.out.println("Program finished.");
⚠️ Common Mistakes:
• if (x = 5) is an error. Use == to compare.
• Never put a semicolon after the condition: if (age >= 18); creates an empty body.

A.2 The if...else Statement

Chooses between two paths. Exactly one block always executes.

if (n % 2 == 0) { System.out.println(n + " is Even"); } else { System.out.println(n + " is Odd"); }

A.3 The else if Ladder

For more than two possibilities. Java checks top-to-bottom and runs the first true branch.

if (marks >= 75) System.out.println("A"); else if (marks >= 65) System.out.println("B"); else if (marks >= 55) System.out.println("C"); else System.out.println("Fail");
💡 Order matters! Always test the most restrictive condition first. If you wrote marks >= 55 first, a student with 90 marks would incorrectly get "C".

A.4 Nested if

An if inside another if. Used when a second decision depends on the first.

if (age >= 18) { if (hasTestPassed) { System.out.println("Licence issued."); } else { System.out.println("Please pass the driving test first."); } } else { System.out.println("You are too young to apply."); }

A.5 The switch Statement

Cleaner than else if when comparing one variable against exact constant values.

switch (day) { case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; case 3: System.out.println("Wednesday"); break; default: System.out.println("Invalid day"); }
⚠️ Without break, execution "falls through" into the next case. Fall-through can be used intentionally to group cases (e.g., case 6 and case 7 both printing "Weekend").
💡 Ternary Operator (one-line if/else):
String result = (marks >= 40) ? "Pass" : "Fail";
🔁 Part B – Repetition (Loops) ▼

Every loop needs three things: (1) Initialisation, (2) Condition, and (3) Update. Forgetting the update causes an infinite loop.

Loop Comparison

LoopCondition CheckedMin RunsBest Used When
forBefore each iteration0Number of repetitions is known
whileBefore each iteration0Repeat until something happens
do...whileAfter each iteration1Must run at least once (menus, validation)

B.1 The for Loop

// Print 1 to 10 for (int i = 1; i <= 10; i++) { System.out.println(i); } // Count down for (int i = 10; i >= 1; i--) { ... } // Step by 2 (even numbers) for (int i = 2; i <= 20; i += 2) { ... }

B.2 The while Loop

int i = 1; while (i <= 5) { System.out.println(i); i++; // Don't forget this! }

B.3 The do...while Loop

do { System.out.print("Enter a positive number: "); number = input.nextInt(); } while (number <= 0); // Note the semicolon!

B.4 Nested Loops

A loop inside another loop. The inner loop completes fully for each outer iteration.

// Triangle pattern for (int i = 1; i <= 5; i++) { for (int j = 1; j <= i; j++) { System.out.print("*"); } System.out.println(); } // Output: * ** *** **** *****

B.5 break vs continue

break

Immediately terminates the entire loop. Control goes to the statement after the loop.

continue

Skips the rest of the current iteration and jumps to the next one. The loop itself continues.

⚠️ Common Loop Mistakes:
• Infinite loop: forgetting i++
• Off-by-one: using < instead of <=
• Semicolon after header: for(...); creates an empty body
✏️ Problem-Solving Exercises (1–10) ▼

Combine selection and repetition. Add import java.util.Scanner; and create Scanner input = new Scanner(System.in); where needed.

Ex 1–3: Numbers, Even, Odd

// Ex 1: Print 1-100 for (int i = 1; i <= 100; i++) System.out.print(i + " "); // Ex 2: Even numbers (efficient - step by 2) for (int i = 2; i <= 100; i += 2) System.out.print(i + " "); // Ex 3: Odd numbers for (int i = 1; i <= 100; i += 2) System.out.print(i + " ");

Ex 4: Multiplication Table

int n = input.nextInt(); for (int i = 1; i <= 10; i++) { System.out.println(n + " x " + i + " = " + (n * i)); }

Ex 5: Sum of Numbers (Accumulator)

int sum = 0; for (int i = 1; i <= n; i++) sum += i; System.out.println("Sum = " + sum);

Ex 6: Factorial

long fact = 1; // Use long! int overflows after 12! for (int i = 2; i <= n; i++) fact *= i; System.out.println(n + "! = " + fact);

Ex 7: Largest of 3 Numbers

int largest = a; // Assume a is largest if (b > largest) largest = b; if (c > largest) largest = c; System.out.println("Largest = " + largest);

Ex 8: Prime Number Check

boolean isPrime = true; if (n <= 1) isPrime = false; else { for (int i = 2; i * i <= n; i++) { if (n % i == 0) { isPrime = false; break; } } }

Ex 9: Reverse a Number

int rev = 0; while (n > 0) { int digit = n % 10; // Get last digit rev = rev * 10 + digit; // Build reversed n = n / 10; // Drop last digit }

Ex 10: Palindrome Check

int original = n; // Keep a copy! // ... reverse logic from Ex 9 ... if (original == rev) System.out.println("Palindrome"); else System.out.println("NOT a Palindrome");
⚙️ Part C – Methods (Reusable Code Blocks) ▼

Methods let you reuse code, break problems into parts, and make programs easier to read and test.

Method Anatomy

public static int add(int a, int b) { return a + b; }
PartExampleMeaning
Access modifierpublicWho can call it
staticstaticBelongs to class (callable from main)
Return typeintType of value returned (void = nothing)
NameaddcamelCase verb
Parametersint a, int bInputs (type + name)
Body{ return a+b; }The code that runs

Key Concepts

Parameters vs Arguments

Parameters are in the definition. Arguments are actual values passed in the call.

Pass by Value

Java passes a copy. Changing a parameter inside a method does NOT change the original variable.

void Methods

Return nothing. Just perform an action. Cannot be assigned to a variable.

Local Variables

Declared inside a method. Exist only during that method's execution. Not visible outside.

Overloading

Same name, different parameters. Java picks the right one based on arguments.

Calling Methods

Methods can call other methods. E.g., sumOfSquares() calls square() twice.

⚠️ A non-void method MUST return a value on every path. Missing return = compile error.
🏗️ Part D – OOP Fundamentals (Classes & Objects) ▼

OOP organises programs around objects that combine data (fields) and behaviour (methods).

💡 Analogy: A class is like an architect's blueprint. An object is an actual house built from that blueprint. One blueprint → many houses.

D.1 Class Definition

class Student { String name; // Field (instance variable) int age; // Field }

D.2 Creating Objects

Student s1 = new Student(); s1.name = "Kamal"; s1.age = 20; Student s2 = new Student(); // Independent object s2.name = "Nimali";

D.3 Constructors

Special method that runs automatically when new is used. Same name as class, no return type.

Student(String name, int age) { this.name = name; // 'this' refers to the field this.age = age; // Without 'this', parameter assigns to itself! }
⚠️ name = name; assigns the parameter to itself (field stays null). Always use this.name = name;

D.4 Instance vs Static Variables

Instance VariableStatic (Class) Variable
Declared without staticDeclared with static
Separate copy per objectONE copy shared by all objects
Accessed via object: s1.nameAccessed via class: Student.count
For object data (name, age)For shared data (counters, constants)

D.5 State & Behaviour

State (Fields)

The data stored: name="Kamal", age=20

Behaviour (Methods)

What it can do: display(), isAdult(), birthday()

Calling a method can change the object's state: s1.birthday() increases age.

🎓 Mini Project – Student Management v1 ▼

A complete example combining classes, constructors, methods, and static variables.

Student.java

public class Student { String name; int age; double marks; static int count = 0; // Shared counter Student(String name, int age, double marks) { this.name = name; this.age = age; this.marks = marks; count++; } String getGrade() { if (marks >= 75) return "A"; else if (marks >= 65) return "B"; else if (marks >= 55) return "C"; else return "Fail"; } void display() { System.out.println("Name : " + name); System.out.println("Age : " + age); System.out.println("Marks: " + marks); System.out.println("Grade: " + getGrade()); System.out.println("-------------------"); } }

Main.java

public class Main { public static void main(String[] args) { Student s1 = new Student("Kamal", 20, 78.5); Student s2 = new Student("Nimali", 19, 66); Student s3 = new Student("Sunil", 21, 48); s1.display(); s2.display(); s3.display(); System.out.println("Total students: " + Student.count); } }

Expected Output

Name : Kamal Age : 20 Marks: 78.5 Grade: A ------------------- Name : Nimali Age : 19 Marks: 66.0 Grade: B ------------------- Name : Sunil Age : 21 Marks: 48.0 Grade: Fail ------------------- Total students: 3
💡 Extension Ideas: Add isAdult(), birthday(), isPass() methods. Add keyboard input with Scanner + loop. Add a second constructor.
📋 Quick Revision Summary & Practice Questions ▼

Key Takeaways

  • if, else if, switch make decisions. switch needs break.
  • for = known count. while = unknown (may run 0×). do...while = at least once.
  • break exits loop. continue skips to next iteration.
  • Method = return type + name + parameters + body. void returns nothing.
  • Class = blueprint. Object = instance created with new.
  • this = current object. Instance vars = per object. Static vars = shared.

Practice Questions

  1. Read marks and print grade using if...else if AND using switch(marks/10).
  2. Print pattern with nested loops: row 1=1, row 2=1 2, row 3=1 2 3, up to row 5.
  3. What is the difference between while and do...while? Give a case where do...while is better.
  4. Write static double average(int a, int b, int c) and call it from main.
  5. Output of: for(int i=1; i<=5; i++){ if(i==3) continue; System.out.print(i); }?
  6. Create class Book with title, price, constructor, and display(). Create 3 books.
  7. Explain instance vs static variable with an example.
  8. Why does name = name; in a constructor fail? How do you fix it?
🎓 SRI LANKA ONLINE ICT TRAINING

Expert ICT, Computer Science, Coding & Digital Marketing Classes

Learn ICT, Computer Science, Programming, Web Development and Digital Marketing with practical, career-focused guidance.

💬 Join WhatsApp ▶ Watch Tutorials

🚀 Learn Today. Build Tomorrow.

Welcome to our Sri Lanka Online ICT & Computer Classes community! We provide Online Tuition Classes, Home Visit Classes and Individual / Group Classes for students and professionals. Whether you are a school student, university student, beginner programmer or entrepreneur, we help you develop practical IT skills for education and career growth.

💡 Explore Our Training & Services

🎓 University Project Guidance

Technical guidance for university assignments and final-year IT projects.

  • BIT / BSc / IT / ICT Projects
  • Final Year Project Guidance
  • PHP & MySQL Projects
  • Python & Java Projects
  • Database & Web Applications
  • Project Ideas & Documentation

🤖 AI, Coding & Software

Develop programming knowledge and practical software development skills.

  • Python Programming
  • C & Java Programming
  • PHP & JavaScript
  • HTML & CSS
  • jQuery & AJAX
  • AI & Smart Applications

🏫 School ICT Classes

Interactive ICT and Computer Science lessons for school students.

  • Grade 1 – Grade 11
  • G.C.E. O/L ICT
  • G.C.E. A/L ICT
  • GIT Classes
  • School ICT & Internal Tests
  • Past Papers & Revision

🌐 Web Design & Development

Build websites and database-driven applications for individuals and businesses.

  • Website Design
  • Website Development
  • WordPress Development
  • PHP & MySQL
  • HTML / CSS / JavaScript
  • Website SEO & Maintenance

📢 Digital Marketing

Grow your brand online with social media and digital marketing support.

  • Digital Marketing
  • Facebook Page Management
  • Instagram Marketing
  • TikTok & YouTube
  • Content Creation & SEO
  • Facebook Ads & Reels

💻 Computer & IT Skills

Build essential computer skills from absolute beginner to advanced level.

  • Computer Fundamentals
  • MS Word, Excel & PowerPoint
  • Excel Formulas & Macros
  • Oracle / MySQL / MS SQL
  • AWS, Linux & DevOps
  • Freelancing & IT Skills

📚 Learn With Your Curriculum

Support for Sri Lankan Local Curriculum, Cambridge and Pearson Edexcel programs.

🇱🇰 Sri Lankan Local Curriculum

  • Grade 01 – Grade 11 ICT
  • G.C.E. O/L ICT
  • G.C.E. A/L ICT
  • GIT Classes
  • Term Test Preparation
  • Model Papers & Notes
  • English / Sinhala / Tamil Medium

📘 Pearson Edexcel

  • iPrimary Computing
  • iLowerSecondary Computing
  • International GCSE ICT
  • International GCSE Computer Science
  • GCSE Computer Science
  • International A Level IT
  • International A Level Computer Science

📗 Cambridge Curriculum

  • Cambridge Primary Computing
  • Cambridge Lower Secondary Computing
  • Cambridge IGCSE ICT
  • Cambridge IGCSE Computer Science
  • Cambridge O Level Computer Science
  • AS & A Level IT
  • AS & A Level Computer Science

💻 Programming & Software Development

🛠️ Programming Languages & Technologies

✅ Python Programming ✅ C Programming ✅ Java Programming
✅ PHP Programming ✅ JavaScript ✅ HTML & CSS
✅ jQuery & AJAX ✅ ASP.NET ✅ VB.NET
✅ VB6 ✅ MySQL ✅ MS SQL Server
✅ MS Access ✅ Oracle Database ✅ Database Design
✅ SQL Queries ✅ Database Programming ✅ Software Development

🌐 Web Design & Development

  • ✅ Website Design
  • ✅ Website Development
  • ✅ WordPress Website Development
  • ✅ HTML / CSS / JavaScript
  • ✅ PHP & MySQL
  • ✅ WordPress SEO
  • ✅ Website Maintenance
  • ✅ Web Applications
  • ✅ Database-Driven Websites

🎓 University & Final Year IT Projects

🧑‍💻 Project Development

  • BIT / BSc / IT / ICT Projects
  • PHP & MySQL Projects
  • Python Projects
  • Java Projects
  • Web Application Projects
  • Database Projects

📄 Documentation & Practical

  • Project Ideas
  • System Architecture
  • Database Design
  • Assignments Guidance
  • Practical Implementation
  • Technical Documentation

🧠 AI & Smart Applications

  • AI Application Concepts
  • Machine Learning Modules
  • Automation Applications
  • Step-by-Step Coding
  • System Implementation
  • Project Learning Support

📊 Database, Cloud & IT Training

✅ Oracle Database ✅ MySQL ✅ Microsoft SQL Server
✅ Microsoft Access ✅ Database Design ✅ SQL Queries
✅ AWS Cloud ✅ Linux ✅ UNIX
✅ Windows Server ✅ DevOps ✅ SRE
✅ Automation ✅ Software Testing ✅ Freelancing Skills

📱 Digital Marketing & Social Media

✅ Digital Marketing ✅ Facebook Page Setup & Management
✅ Instagram Marketing ✅ TikTok Marketing
✅ YouTube Channel Setup ✅ Social Media Management
✅ Content Creation ✅ SEO
✅ Facebook Ads ✅ Instagram Reels
✅ LinkedIn Branding ✅ Social Media Campaign Planning
✅ Hashtag Strategy ✅ Insights & Engagement

🖥️ Microsoft Office & Digital Skills

  • ✅ MS Word
  • ✅ MS Excel
  • ✅ MS PowerPoint
  • ✅ Excel Formulas
  • ✅ Excel Automation & Macros
  • ✅ Computer Fundamentals
  • ✅ Digital Literacy
  • ✅ Multimedia Presentations

⭐ Why Join Our Classes?

🌍
Online & Home Visit Classes
👥
Individual & Group Classes
🗣️
English / Sinhala / Tamil
📚
School & University Support
📝
Past Papers & Model Papers
💻
Practical Programming
🚀
Beginner to Advanced Skills
🎯
Career-Focused Learning

📞 Ready to Start Learning?

Book your online class or contact us for ICT training, programming courses, university project guidance and digital marketing services.

📱 Call / WhatsApp: +94 729622034

📧 Email: itclasssl@gmail.com

💻 Skype: ITClassSL

💬 Contact Us on WhatsApp

🌐 Our Online Learning Platforms

Explore tutorials, notes, project guides and learning resources.

📺 YouTube Tutorials
Watch ICT & programming videos
💬 WhatsApp Community
Join our learning community
✍️ ICT Blog
Computer classes and tutorials
📰 WordPress
Notes and learning resources
📘 Facebook
Follow our official page
🌐 Wix Website
Explore our training services
💻 eTeacher Website
Online learning platform
📝 Medium
Read technology articles
❓ Quora
Project guidance and Q&A
🎓 Strikingly Portfolio
University project resources
🗣️ ElaKiri Forum
Join the project discussion
🎵 TikTok
Follow our learning videos
🛒 Payhip
Explore our digital resources
🌐 Weebly
Project and IT resources

ITClassSL — ICT Training | Computer Classes | Programming | University Project Guidance | Digital Marketing

Learn • Practice • Build • Grow 🚀

Tuesday, October 6, 2026

GCE A/L ICT Competency 11.1 - IoT & Embedded Systems Notes Questions and Answers Model Paper Online ICT Classes

🌐 G.C.E. A/L ICT – Competency 11.1

Internet of Things (IoT) | Basic Digital / Embedded System Building Blocks | Arduino & Practical Applications

Embedded Systems Microcontroller Development Board Arduino IDE Sensors & Outputs
🧠 1. Embedded System (உட்பொதிக்கப்பட்ட அமைப்பு) ▼
எளிய வரையறை:
ஒரு குறிப்பிட்ட செயல்பாட்டை கட்டுப்படுத்துவதற்காக ஒரு electronic/mechanical சாதனத்திற்குள் பொருத்தப்பட்ட கணினி அமைப்பு Embedded System எனப்படும்.

உதாரணங்கள்

Washing machine Microwave oven Digital camera Traffic light controller Air conditioner Car engine control Smart security system

Example: Automatic Fan System

Temperature Sensor (Input) ↓ Microcontroller (Decision) ↓ Fan (Output ON/OFF)

Logic:
Temperature > 30°C → Fan ON
Temperature ≤ 30°C → Fan OFF

இதுவே ஒரு சிறிய Embedded System ஆகும்.

⚙️ 2. Microprocessor vs Microcontroller ▼

இந்த இரண்டு சொற்களையும் exam-ல் குழப்பிக்கொள்ள கூடாது.

Microprocessor

CPU-வை மட்டும் ஒரு chip-ல் கொண்ட processing unit. RAM, Storage, I/O போன்றவை வெளிப்புறமாக தேவைப்படும்.

Example: Intel Core, AMD (Desktop PCs)

Microcontroller

CPU, Memory, I/O ports, Timers, ADC போன்ற அனைத்தும் ஒரே chip-ல் ஒருங்கிணைக்கப்பட்ட சிறிய control computer.

Example: ATmega328P (Arduino-வில்)

🛠️ 3. Development Board & PC vs Dev Board ▼

Development Board என்பது மாணவர்கள்/Developers electronic applications உருவாக்கவும், program செய்யவும் பயன்படுத்தும் ஒரு platform ஆகும்.

Examples: Arduino, Raspberry Pi, Micro:bit

Traditional Computer vs Development Board

Traditional Computer (PC)Development Board (Arduino)
General-purpose tasksSpecific control tasks
Keyboard, mouse (Inputs)Sensors, switches (Inputs)
Monitor, printer (Outputs)LED, motor, fan (Outputs)
பெரிய Operating System தேவைசிறிய control program போதுமானது
அதிக processing resourcesகுறைந்த resources-ல் வேலை செய்யும்
General computingEmbedded / physical control
📟 4. Arduino Board – முக்கிய Building Blocks ▼

Analog Input

தொடர்ச்சியாக மாறக்கூடிய values (Temperature, Light). ADC மூலம் 0-1023 digital value ஆக மாற்றப்படும்.

Digital Input / Output

இரண்டு நிலைகள் மட்டுமே: HIGH (1) அல்லது LOW (0). (Eg: Push button, LED).

RX / TX Pins

RX (Receive): Data பெற (Pin 0).
TX (Transmit): Data அனுப்ப (Pin 1). Serial communication-க்கு பயன்படும்.

USB Port

Computer-க்கு connect செய்து Program upload செய்யவும், Power supply வழங்கவும் பயன்படும்.

Power Supply

Board இயங்க தேவையான மின்சாரம் (USB வழியாகவோ அல்லது External adapter வழியாகவோ).

Reset Switch

இதை அழுத்தினால் board-ன் program execution மீண்டும் ஆரம்ப நிலையிலிருந்து (setup) தொடங்கும்.

💻 5. IDE & Arduino Program Structure ▼

IDE (Integrated Development Environment): Code எழுத, Compile செய்ய மற்றும் Board-க்கு Upload செய்ய உதவும் software. (Eg: Arduino IDE).

Program Workflow

Source Code (Editor) ↓ Compiler (Machine Code ஆக மாற்றும்) ↓ Upload / Programmer (Board-ன் Memory-க்கு அனுப்பும்) ↓ Microcontroller (Execute செய்யும்)

Basic Arduino Structure

void setup() { // Program ஆரம்பிக்கும்போது ஒருமுறை மட்டும் execute ஆகும். // Eg: Pin-ஐ Output ஆக அமைத்தல் } void loop() { // setup() முடிந்த பிறகு தொடர்ந்து (முடிவில்லாமல்) repeat ஆகும். // Eg: Sensor reading, LED ON/OFF }
💡 6. Practical App 1: LED ON/OFF (Blinking) ▼

Logic

Set LED pin as OUTPUT → LED ON → Wait → LED OFF → Wait → Repeat

Arduino Code

int ledPin = 13; void setup() { pinMode(ledPin, OUTPUT); // Pin-ஐ output ஆக அமைக்கிறது } void loop() { digitalWrite(ledPin, HIGH); // LED ON delay(1000); // 1 second (1000ms) காத்திருக்கிறது digitalWrite(ledPin, LOW); // LED OFF delay(1000); // 1 second காத்திருக்கிறது }
🌗 7. Practical App 2: Automatic Light (LDR) ▼
LDR (Light Dependent Resistor): ஒளியின் intensity-க்கு ஏற்ப resistance மாறும் component. இது Analog Input-க்கு அனுப்பப்படும்.

Algorithm / Pseudocode

START Read light intensity (from LDR) IF light intensity < threshold (Eg: 400) LED = ON (இருட்டு) ELSE LED = OFF (வெளிச்சம்) REPEAT
⭐ Exam Logic Question:
"Design a system that switches an LED ON when the ambient light intensity becomes low."

Answer Structure:
Input: LDR → Processing: Microcontroller → Decision: Compare with threshold → Output: LED
🌡️ 8. Practical App 3: Temperature Sensor + Fan ▼

Pseudocode

START temperature = READ SENSOR IF temperature > 30 TURN FAN ON ELSE TURN FAN OFF REPEAT

⚠️ முக்கிய குறிப்பு (Driver/Relay)

பெரிய Fan/Motor-ஐ Arduino I/O pin-க்கு நேரடியாக இணைக்கக் கூடாது. Microcontroller pin குறைந்த current-ஐ மட்டுமே வழங்கும். எனவே Driver circuit / Relay / Transistor மற்றும் தனி Power Supply தேவைப்படும்.

🚪 9. Practical App 4: Door Detection (Reed Switch) ▼

Reed Switch: Magnetic field மூலம் open/close ஆகும் switch. கதவில் Magnet-ஐயும், Door Frame-ல் Reed Switch-ஐயும் பொருத்துவோம்.

Logic

  • Door Closed → Magnet அருகில் உள்ளது → LED OFF / Buzzer OFF
  • Door Open → Magnet விலகுகிறது → LED ON / Buzzer ON (Alarm)

Pseudocode

START Read reed switch (Digital Input) IF door is open Turn ON Alarm / LED ELSE Turn OFF Alarm / LED REPEAT
🏆 10. Master Summary (Input → Process → Output) ▼

இந்த competency-யின் மிக முக்கியமான Concept-ஐ இந்த அட்டவணையில் மனப்பாடம் செய்யுங்கள்:

Application Input (Sensor) Processing Output
LED Control Switch / Program Microcontroller LED
Automatic Light LDR (Analog) Microcontroller LED / Bulb
Automatic Fan Temperature Sensor Microcontroller Fan (via Relay)
Door Detection Reed Switch (Digital) Microcontroller LED / Buzzer
🎓 SRI LANKA ONLINE ICT TRAINING

Expert ICT, Computer Science, Coding & Digital Marketing Classes

Learn ICT, Computer Science, Programming, Web Development and Digital Marketing with practical, career-focused guidance.

💬 Join WhatsApp ▶ Watch Tutorials

🚀 Learn Today. Build Tomorrow.

Welcome to our Sri Lanka Online ICT & Computer Classes community! We provide Online Tuition Classes, Home Visit Classes and Individual / Group Classes for students and professionals. Whether you are a school student, university student, beginner programmer or entrepreneur, we help you develop practical IT skills for education and career growth.

💡 Explore Our Training & Services

🎓 University Project Guidance

Technical guidance for university assignments and final-year IT projects.

  • BIT / BSc / IT / ICT Projects
  • Final Year Project Guidance
  • PHP & MySQL Projects
  • Python & Java Projects
  • Database & Web Applications
  • Project Ideas & Documentation

🤖 AI, Coding & Software

Develop programming knowledge and practical software development skills.

  • Python Programming
  • C & Java Programming
  • PHP & JavaScript
  • HTML & CSS
  • jQuery & AJAX
  • AI & Smart Applications

🏫 School ICT Classes

Interactive ICT and Computer Science lessons for school students.

  • Grade 1 – Grade 11
  • G.C.E. O/L ICT
  • G.C.E. A/L ICT
  • GIT Classes
  • School ICT & Internal Tests
  • Past Papers & Revision

🌐 Web Design & Development

Build websites and database-driven applications for individuals and businesses.

  • Website Design
  • Website Development
  • WordPress Development
  • PHP & MySQL
  • HTML / CSS / JavaScript
  • Website SEO & Maintenance

📢 Digital Marketing

Grow your brand online with social media and digital marketing support.

  • Digital Marketing
  • Facebook Page Management
  • Instagram Marketing
  • TikTok & YouTube
  • Content Creation & SEO
  • Facebook Ads & Reels

💻 Computer & IT Skills

Build essential computer skills from absolute beginner to advanced level.

  • Computer Fundamentals
  • MS Word, Excel & PowerPoint
  • Excel Formulas & Macros
  • Oracle / MySQL / MS SQL
  • AWS, Linux & DevOps
  • Freelancing & IT Skills

📚 Learn With Your Curriculum

Support for Sri Lankan Local Curriculum, Cambridge and Pearson Edexcel programs.

🇱🇰 Sri Lankan Local Curriculum

  • Grade 01 – Grade 11 ICT
  • G.C.E. O/L ICT
  • G.C.E. A/L ICT
  • GIT Classes
  • Term Test Preparation
  • Model Papers & Notes
  • English / Sinhala / Tamil Medium

📘 Pearson Edexcel

  • iPrimary Computing
  • iLowerSecondary Computing
  • International GCSE ICT
  • International GCSE Computer Science
  • GCSE Computer Science
  • International A Level IT
  • International A Level Computer Science

📗 Cambridge Curriculum

  • Cambridge Primary Computing
  • Cambridge Lower Secondary Computing
  • Cambridge IGCSE ICT
  • Cambridge IGCSE Computer Science
  • Cambridge O Level Computer Science
  • AS & A Level IT
  • AS & A Level Computer Science

💻 Programming & Software Development

🛠️ Programming Languages & Technologies

✅ Python Programming ✅ C Programming ✅ Java Programming
✅ PHP Programming ✅ JavaScript ✅ HTML & CSS
✅ jQuery & AJAX ✅ ASP.NET ✅ VB.NET
✅ VB6 ✅ MySQL ✅ MS SQL Server
✅ MS Access ✅ Oracle Database ✅ Database Design
✅ SQL Queries ✅ Database Programming ✅ Software Development

🌐 Web Design & Development

  • ✅ Website Design
  • ✅ Website Development
  • ✅ WordPress Website Development
  • ✅ HTML / CSS / JavaScript
  • ✅ PHP & MySQL
  • ✅ WordPress SEO
  • ✅ Website Maintenance
  • ✅ Web Applications
  • ✅ Database-Driven Websites

🎓 University & Final Year IT Projects

🧑‍💻 Project Development

  • BIT / BSc / IT / ICT Projects
  • PHP & MySQL Projects
  • Python Projects
  • Java Projects
  • Web Application Projects
  • Database Projects

📄 Documentation & Practical

  • Project Ideas
  • System Architecture
  • Database Design
  • Assignments Guidance
  • Practical Implementation
  • Technical Documentation

🧠 AI & Smart Applications

  • AI Application Concepts
  • Machine Learning Modules
  • Automation Applications
  • Step-by-Step Coding
  • System Implementation
  • Project Learning Support

📊 Database, Cloud & IT Training

✅ Oracle Database ✅ MySQL ✅ Microsoft SQL Server
✅ Microsoft Access ✅ Database Design ✅ SQL Queries
✅ AWS Cloud ✅ Linux ✅ UNIX
✅ Windows Server ✅ DevOps ✅ SRE
✅ Automation ✅ Software Testing ✅ Freelancing Skills

📱 Digital Marketing & Social Media

✅ Digital Marketing ✅ Facebook Page Setup & Management
✅ Instagram Marketing ✅ TikTok Marketing
✅ YouTube Channel Setup ✅ Social Media Management
✅ Content Creation ✅ SEO
✅ Facebook Ads ✅ Instagram Reels
✅ LinkedIn Branding ✅ Social Media Campaign Planning
✅ Hashtag Strategy ✅ Insights & Engagement

🖥️ Microsoft Office & Digital Skills

  • ✅ MS Word
  • ✅ MS Excel
  • ✅ MS PowerPoint
  • ✅ Excel Formulas
  • ✅ Excel Automation & Macros
  • ✅ Computer Fundamentals
  • ✅ Digital Literacy
  • ✅ Multimedia Presentations

⭐ Why Join Our Classes?

🌍
Online & Home Visit Classes
👥
Individual & Group Classes
🗣️
English / Sinhala / Tamil
📚
School & University Support
📝
Past Papers & Model Papers
💻
Practical Programming
🚀
Beginner to Advanced Skills
🎯
Career-Focused Learning

📞 Ready to Start Learning?

Book your online class or contact us for ICT training, programming courses, university project guidance and digital marketing services.

📱 Call / WhatsApp: +94 729622034

📧 Email: itclasssl@gmail.com

💻 Skype: ITClassSL

💬 Contact Us on WhatsApp

🌐 Our Online Learning Platforms

Explore tutorials, notes, project guides and learning resources.

📺 YouTube Tutorials
Watch ICT & programming videos
💬 WhatsApp Community
Join our learning community
✍️ ICT Blog
Computer classes and tutorials
📰 WordPress
Notes and learning resources
📘 Facebook
Follow our official page
🌐 Wix Website
Explore our training services
💻 eTeacher Website
Online learning platform
📝 Medium
Read technology articles
❓ Quora
Project guidance and Q&A
🎓 Strikingly Portfolio
University project resources
🗣️ ElaKiri Forum
Join the project discussion
🎵 TikTok
Follow our learning videos
🛒 Payhip
Explore our digital resources
🌐 Weebly
Project and IT resources

ITClassSL — ICT Training | Computer Classes | Programming | University Project Guidance | Digital Marketing

Learn • Practice • Build • Grow 🚀

Monday, October 5, 2026

Java Class 1 notes computer science university programming basics, JDK/JRE/JVM, variables, data types, operators, type casting, Scanner input, and practical exercises with solutions

☕ Java Fundamentals & Program Development

Class 1 Complete Notes | From Basics to Mini Project

📚 About this guide: Complete, exam-friendly notes for Java Class 1: Fundamentals & Program Development. Covers Programming Basics, JDK/JRE/JVM, Variables, Data Types, Operators, Scanner Input, Type Casting, and Practical Exercises with step-by-step code explanations.
1.1 - 1.3

Programming, Algorithms & Source Code

  • Programming: Writing instructions that tell a computer how to perform a task.
  • Algorithm: A step-by-step, language-independent procedure to solve a problem (like a recipe idea).
  • Program: The implementation of an algorithm in a specific language (like the recipe written in English).
  • Source Code: Human-readable text written by the programmer (saved as .java files).
1.4 - 1.5

Compiler, JDK, JRE & JVM

ComponentContainsUsed For
JVMBytecode interpreterExecuting bytecode ("Write Once, Run Anywhere")
JREJVM + LibrariesRunning Java programs
JDKJRE + Compiler (javac) + ToolsDeveloping and compiling programs

Flow: Main.java → (javac) → Main.class (bytecode) → (JVM) → Output

1.7 - 1.8

Syntax vs Semantics & Types of Errors

  • Syntax: Grammar rules of the language (e.g., missing semicolon).
  • Semantics: The actual meaning/logic of the code (e.g., wrong formula).
Error TypeDetected WhenExample
SyntaxCompile timeMissing ; or invalid variable name
RuntimeWhile runningDividing by zero (ArithmeticException)
LogicalChecking outputWrong formula (Compiles & runs, but gives wrong answer)
2.1

GUI vs CLI

  • GUI (Graphical User Interface): Interact using windows, icons, menus, and a mouse. (Easy for beginners).
  • CLI (Command Line Interface): Interact by typing text commands into a terminal. (Faster for developers, used for compiling/running).
2.3

Text Editors vs IDEs

FeatureText Editor (Notepad)IDE (IntelliJ, Eclipse)
Edit codeYesYes
Compile & RunManually via CLIBuilt-in button
Error detectionNoYes, live underlining
Auto-completeLimitedYes, smart suggestions
2.4

Popular Java IDEs

  • IntelliJ IDEA: Popular, smart code completion, very beginner-friendly (Community Edition is free).
  • Eclipse: Long-established, free, open-source, widely used in universities.
  • VS Code: Lightweight editor that becomes a Java IDE after installing the Java Extension Pack.
3.0

Hello World Program

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello World");
    }
}
4.0

Line-by-Line Breakdown

  • public class Main: All Java code must be inside a class. If public, file name must match (Main.java).
  • public static void main(String[] args): The entry point. public (accessible anywhere), static (runs without creating an object), void (returns nothing), String[] args (command-line arguments).
  • System.out.println(): Prints text to the console and moves to a new line. (Use print() to stay on the same line).
🎯 Golden Rules: Every statement ends with ; | Java is case-sensitive | Blocks use {} | Text uses ""
5.1

Variables & Naming Rules

A variable is a named memory location that stores a value. Java is statically typed (must declare type).

Syntax: dataType variableName = value;

Rules: Can contain letters, digits, _, $. Cannot start with a digit. Cannot be a keyword. Use camelCase by convention.

5.2

Primitive vs Reference Data Types

TypeStoresSizeExample
intWhole numbers4 bytesint age = 25;
doubleDecimals (15 digits precision)8 bytesdouble price = 99.75;
floatDecimals (7 digits precision)4 bytesfloat temp = 36.5f; (Needs f)
charSingle character2 byteschar grade = 'A'; (Single quotes)
booleantrue or false1 bitboolean pass = true;
StringText (Class, not primitive)VariesString name = "Ali"; (Double quotes)
5.3

Constants (final keyword)

A constant's value cannot be changed after assignment. Use the final keyword. Convention: UPPERCASE_WITH_UNDERSCORES.

final double PI = 3.14159;
final int MAX_MARKS = 100;
// PI = 3.14;  ERROR: cannot assign a value to final variable
6.0

Getting User Input (Scanner)

import java.util.Scanner; // 1. Import

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in); // 2. Create object
        
        System.out.print("Enter your age: ");
        int age = input.nextInt(); // 3. Read input
        
        System.out.println("You are " + age + " years old.");
        input.close();
    }
}
⚠️ Common Pitfall: After nextInt(), the Enter key (newline) stays in the buffer. If you use nextLine() next, it will read an empty string. Fix: Add an extra input.nextLine(); to consume the leftover newline.
7.0

Arithmetic, Relational & Logical Operators

  • Arithmetic: +, -, *, / (Integer division drops decimals!), % (Modulus/Remainder).
  • Relational: == (Equal), != (Not equal), >, <, >=, <=. (Returns boolean).
  • Logical: && (AND), || (OR), ! (NOT).
  • Increment/Decrement: x++ (post-increment: use then increase), ++x (pre-increment: increase then use).
8.2

Automatic Conversion (Widening)

Java automatically converts a smaller type to a larger type without data loss.

Order: byte → short → int → long → float → double

int a = 10;
double b = 3; // 3 becomes 3.0 automatically
double result = a / b; // 10.0 / 3.0 = 3.333...
8.3

Explicit Conversion (Narrowing / Casting)

Converting a larger type to a smaller type must be done manually using a cast. Data may be lost (decimals are truncated, not rounded).

double price = 99.99;
int rounded = (int) price; // 99 (decimal part is cut off)

// int x = 7.5; ERROR: possible lossy conversion
int y = (int) 7.5; // OK, y = 7
8.4

Casting to Fix Integer Division

If you divide two integers, Java performs integer division. Cast before dividing to get a decimal result.

int total = 17;
int count = 5;

double wrong = total / count; // 3.0 (Integer division happened first!)
double correct = (double) total / count; // 3.4 (Cast applied first)
Ex 1-4

Quick Exercise Formulas

  • Area of Circle: PI * radius * radius
  • Area of Rectangle: length * width
  • Simple Interest: (principal * rate * time) / 100
  • Celsius to Fahrenheit: (celsius * 9.0 / 5) + 32 (Use 9.0 to avoid integer division!)
Mini Project

Student Marks Calculator

Accepts name and 3 subject marks, then calculates total, average, and pass/fail result.

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.print("Enter student name: ");
        String name = input.nextLine();

        System.out.print("Enter marks for subject 1: ");
        int m1 = input.nextInt();
        System.out.print("Enter marks for subject 2: ");
        int m2 = input.nextInt();
        System.out.print("Enter marks for subject 3: ");
        int m3 = input.nextInt();

        int total = m1 + m2 + m3;
        double average = total / 3.0; // 3.0 forces decimal division

        // Ternary operator (short if/else)
        String result = (average >= 40) ? "Pass" : "Fail";

        System.out.println("\n------ Result Sheet------");
        System.out.println("Name   : " + name);
        System.out.println("Total  : " + total);
        System.out.printf("Average: %.2f%n", average); // 2 decimal places
        System.out.println("Result : " + result);

        input.close();
    }
}

📌 Quick Revision Summary

⭐ Core Concepts:
🔄 Flow: .java (Source) → javac → .class (Bytecode) → JVM → Output
📦 JDK ⊃ JRE ⊃ JVM
🐛 Errors: Syntax (Compile), Runtime (Crash), Logical (Wrong Output)
🚪 Entry Point: public static void main(String[] args)
🔢 Types: int, double, float, char, boolean, String
⌨️ Input: Scanner (import java.util.Scanner;)
➗ Division: int/int drops decimals. Cast to double or use .0!
🔄 Casting: Widening (Auto, Safe) | Narrowing (Manual, Data Loss)

📝 Practice Questions

  • Q1: Differentiate between JDK, JRE and JVM.
  • Q2: What is the difference between a compile-time error and a logical error? Give one example of each.
  • Q3: Why is main declared static?
  • Q4: What is the output of System.out.println(7 / 2);? How would you get 3.5?
  • Q5: What is the value of x and y after int x = 5; int y = x++ + ++x;?
  • Q6: Write a program that reads a number of days and prints the equivalent number of weeks and remaining days (Hint: use / and %).

❓ Frequently Asked Questions (FAQ)

Q: What is the difference between JDK, JRE, and JVM? A: JVM (Java Virtual Machine) executes bytecode. JRE (Java Runtime Environment) includes the JVM and standard libraries needed to run programs. JDK (Java Development Kit) includes the JRE plus development tools like the compiler (javac) and debugger, which are needed to write and compile programs.
Q: What are the three types of errors in Java? A: 1. Syntax Errors: Violations of Java's grammar rules detected by the compiler (e.g., missing semicolon). 2. Runtime Errors: Illegal operations that crash the program while running (e.g., dividing by zero). 3. Logical Errors: The program runs without crashing but produces an incorrect result due to flawed logic.
Q: Why is the main method declared static in Java? A: The main method is declared static so that the JVM can call it directly using the class name without needing to create an object (instance) of the class first. This allows the program to start executing immediately.
Q: What is the difference between widening and narrowing in Java? A: Widening (Automatic Conversion) is when Java automatically converts a smaller data type to a larger one (e.g., int to double) without data loss. Narrowing (Explicit Casting) is when you manually convert a larger type to a smaller one (e.g., double to int) using a cast, which may result in data loss.
🎓 SRI LANKA ONLINE ICT TRAINING

Expert ICT, Computer Science, Coding & Digital Marketing Classes

Learn ICT, Computer Science, Programming, Web Development and Digital Marketing with practical, career-focused guidance.

💬 Join WhatsApp ▶ Watch Tutorials

🚀 Learn Today. Build Tomorrow.

Welcome to our Sri Lanka Online ICT & Computer Classes community! We provide Online Tuition Classes, Home Visit Classes and Individual / Group Classes for students and professionals. Whether you are a school student, university student, beginner programmer or entrepreneur, we help you develop practical IT skills for education and career growth.

💡 Explore Our Training & Services

🎓 University Project Guidance

Technical guidance for university assignments and final-year IT projects.

  • BIT / BSc / IT / ICT Projects
  • Final Year Project Guidance
  • PHP & MySQL Projects
  • Python & Java Projects
  • Database & Web Applications
  • Project Ideas & Documentation

🤖 AI, Coding & Software

Develop programming knowledge and practical software development skills.

  • Python Programming
  • C & Java Programming
  • PHP & JavaScript
  • HTML & CSS
  • jQuery & AJAX
  • AI & Smart Applications

🏫 School ICT Classes

Interactive ICT and Computer Science lessons for school students.

  • Grade 1 – Grade 11
  • G.C.E. O/L ICT
  • G.C.E. A/L ICT
  • GIT Classes
  • School ICT & Internal Tests
  • Past Papers & Revision

🌐 Web Design & Development

Build websites and database-driven applications for individuals and businesses.

  • Website Design
  • Website Development
  • WordPress Development
  • PHP & MySQL
  • HTML / CSS / JavaScript
  • Website SEO & Maintenance

📢 Digital Marketing

Grow your brand online with social media and digital marketing support.

  • Digital Marketing
  • Facebook Page Management
  • Instagram Marketing
  • TikTok & YouTube
  • Content Creation & SEO
  • Facebook Ads & Reels

💻 Computer & IT Skills

Build essential computer skills from absolute beginner to advanced level.

  • Computer Fundamentals
  • MS Word, Excel & PowerPoint
  • Excel Formulas & Macros
  • Oracle / MySQL / MS SQL
  • AWS, Linux & DevOps
  • Freelancing & IT Skills

📚 Learn With Your Curriculum

Support for Sri Lankan Local Curriculum, Cambridge and Pearson Edexcel programs.

🇱🇰 Sri Lankan Local Curriculum

  • Grade 01 – Grade 11 ICT
  • G.C.E. O/L ICT
  • G.C.E. A/L ICT
  • GIT Classes
  • Term Test Preparation
  • Model Papers & Notes
  • English / Sinhala / Tamil Medium

📘 Pearson Edexcel

  • iPrimary Computing
  • iLowerSecondary Computing
  • International GCSE ICT
  • International GCSE Computer Science
  • GCSE Computer Science
  • International A Level IT
  • International A Level Computer Science

📗 Cambridge Curriculum

  • Cambridge Primary Computing
  • Cambridge Lower Secondary Computing
  • Cambridge IGCSE ICT
  • Cambridge IGCSE Computer Science
  • Cambridge O Level Computer Science
  • AS & A Level IT
  • AS & A Level Computer Science

💻 Programming & Software Development

🛠️ Programming Languages & Technologies

✅ Python Programming ✅ C Programming ✅ Java Programming
✅ PHP Programming ✅ JavaScript ✅ HTML & CSS
✅ jQuery & AJAX ✅ ASP.NET ✅ VB.NET
✅ VB6 ✅ MySQL ✅ MS SQL Server
✅ MS Access ✅ Oracle Database ✅ Database Design
✅ SQL Queries ✅ Database Programming ✅ Software Development

🌐 Web Design & Development

  • ✅ Website Design
  • ✅ Website Development
  • ✅ WordPress Website Development
  • ✅ HTML / CSS / JavaScript
  • ✅ PHP & MySQL
  • ✅ WordPress SEO
  • ✅ Website Maintenance
  • ✅ Web Applications
  • ✅ Database-Driven Websites

🎓 University & Final Year IT Projects

🧑‍💻 Project Development

  • BIT / BSc / IT / ICT Projects
  • PHP & MySQL Projects
  • Python Projects
  • Java Projects
  • Web Application Projects
  • Database Projects

📄 Documentation & Practical

  • Project Ideas
  • System Architecture
  • Database Design
  • Assignments Guidance
  • Practical Implementation
  • Technical Documentation

🧠 AI & Smart Applications

  • AI Application Concepts
  • Machine Learning Modules
  • Automation Applications
  • Step-by-Step Coding
  • System Implementation
  • Project Learning Support

📊 Database, Cloud & IT Training

✅ Oracle Database ✅ MySQL ✅ Microsoft SQL Server
✅ Microsoft Access ✅ Database Design ✅ SQL Queries
✅ AWS Cloud ✅ Linux ✅ UNIX
✅ Windows Server ✅ DevOps ✅ SRE
✅ Automation ✅ Software Testing ✅ Freelancing Skills

📱 Digital Marketing & Social Media

✅ Digital Marketing ✅ Facebook Page Setup & Management
✅ Instagram Marketing ✅ TikTok Marketing
✅ YouTube Channel Setup ✅ Social Media Management
✅ Content Creation ✅ SEO
✅ Facebook Ads ✅ Instagram Reels
✅ LinkedIn Branding ✅ Social Media Campaign Planning
✅ Hashtag Strategy ✅ Insights & Engagement

🖥️ Microsoft Office & Digital Skills

  • ✅ MS Word
  • ✅ MS Excel
  • ✅ MS PowerPoint
  • ✅ Excel Formulas
  • ✅ Excel Automation & Macros
  • ✅ Computer Fundamentals
  • ✅ Digital Literacy
  • ✅ Multimedia Presentations

⭐ Why Join Our Classes?

🌍
Online & Home Visit Classes
👥
Individual & Group Classes
🗣️
English / Sinhala / Tamil
📚
School & University Support
📝
Past Papers & Model Papers
💻
Practical Programming
🚀
Beginner to Advanced Skills
🎯
Career-Focused Learning

📞 Ready to Start Learning?

Book your online class or contact us for ICT training, programming courses, university project guidance and digital marketing services.

📱 Call / WhatsApp: +94 729622034

📧 Email: itclasssl@gmail.com

💻 Skype: ITClassSL

💬 Contact Us on WhatsApp

🌐 Our Online Learning Platforms

Explore tutorials, notes, project guides and learning resources.

📺 YouTube Tutorials
Watch ICT & programming videos
💬 WhatsApp Community
Join our learning community
✍️ ICT Blog
Computer classes and tutorials
📰 WordPress
Notes and learning resources
📘 Facebook
Follow our official page
🌐 Wix Website
Explore our training services
💻 eTeacher Website
Online learning platform
📝 Medium
Read technology articles
❓ Quora
Project guidance and Q&A
🎓 Strikingly Portfolio
University project resources
🗣️ ElaKiri Forum
Join the project discussion
🎵 TikTok
Follow our learning videos
🛒 Payhip
Explore our digital resources
🌐 Weebly
Project and IT resources

ITClassSL — ICT Training | Computer Classes | Programming | University Project Guidance | Digital Marketing

Learn • Practice • Build • Grow 🚀