Arrays, OOP, Recursion & Algorithms
Master the transition from simple programs to handling multiple data values, advanced Object-Oriented concepts, and standard algorithmic problem-solving.
Class 3, Part A: 1D Arrays & Problem Solving ▼
An array is a container object that holds a fixed number of values of a single type. It allows you to store and manipulate multiple data values efficiently.
Declaration, Creation & Initialization
// Declaration & Initialization int[] marks = {75, 82, 65, 90, 55}; // Key Properties int firstMark = marks[0]; // Index starts at 0 int totalStudents = marks.length; // Length is 5 marks[2] = 70; // Updating a value
Traversing Arrays
Standard For Loop
Best when you need the index to update values or track positions.
for(int i=0; i<marks.length; i++)
Enhanced For-Each Loop
Cleaner syntax for reading values sequentially without modifying the array.
for(int mark : marks)
Array Problem Solving Toolkit
Sum & Average
Use an accumulator variable in a loop. Divide sum by .length for average.
Max & Min
Assume the first element is max/min, then update if a larger/smaller value is found.
Count Even/Odd
Use num % 2 == 0 inside a loop with a counter variable.
Reverse Array
Swap elements from the outside in (index 0 with length-1, etc.).
Searching & Sorting Algorithms ▼
Linear Search
Checking every element one by one until the target is found.
for (int i = 0; i < numbers.length; i++) { if (numbers[i] == target) { System.out.println("Found at index: " + i); break; } }
Basic Sorting Logic
Sorting arranges data in a specific order (ascending/descending).
↓ (Compare & Swap adjacent elements)
Sorted: [ 1, 2, 3, 5, 8 ]
Bubble Sort
Repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.
Selection Sort
Finds the minimum element from the unsorted part and puts it at the beginning of the sorted part.
2D Arrays & Arrays of Objects ▼
2D Arrays (Matrices)
An array of arrays, organized in rows and columns. Requires nested loops to traverse.
int[][] matrix = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9} }; // Nested loops for Matrix Input/Output/Addition for(int i=0; i<matrix.length; i++) { // Rows for(int j=0; j<matrix[i].length; j++) { // Columns System.out.print(matrix[i][j] + " "); } }
Arrays of Objects
This is the crucial bridge connecting Arrays with Object-Oriented Programming (OOP).
Student[] students = new Student[5]; students[0] = new Student("Kamal", 20); students[1] = new Student("Nimal", 21); // Now you can loop through objects! for(Student s : students) { if(s != null) s.display(); }
Part B: Recursion (A Method Calling Itself) ▼
Recursion is a technique where a method solves a problem by calling itself with a smaller version of the problem. It requires a Base Case (to stop) and a Recursive Case (to continue).
Factorial Example
static int factorial(int n) { // Base Case if (n == 0 || n == 1) { return 1; } // Recursive Case return n * factorial(n - 1); }
Visualizing the Stack
↓
5 × factorial(4)
↓
5 × 4 × factorial(3)
↓
5 × 4 × 3 × 2 × factorial(1) → returns 1
↓
Result: 120
StackOverflowError.Practice Problems: Fibonacci sequence, Sum of 1 to n, Reversing a String, Power calculation (x^n).
Class 4, Part A: Inheritance & Polymorphism ▼
Inheritance (The "Is-A" Relationship)
Allows a new class (Child/Subclass) to inherit fields and methods from an existing class (Parent/Superclass) using the extends keyword.
class Person { String name; void displayName() { System.out.println(name); } } class Student extends Person { int marks; // Inherits 'name' and 'displayName()' from Person }
super keyword (calls parent constructor/methods), Access Modifiers (private is hidden, protected is inherited, public is everywhere).Polymorphism (Runtime / Method Overriding)
"Many forms." A parent class reference variable can hold a child class object, and the correct overridden method is called at runtime.
class Animal { void sound() { System.out.println("Animal sound"); } } class Dog extends Animal { @Override void sound() { System.out.println("Bark"); } } class Cat extends Animal { @Override void sound() { System.out.println("Meow"); } } // Runtime Polymorphism Animal a; a = new Dog(); a.sound(); // Output: Bark a = new Cat(); a.sound(); // Output: Meow
Part B: Standard Algorithms (Syllabus Concepts) ▼
The syllabus focuses on the problem-solving concepts behind these classic computer science algorithms.
1. String Matching
Finding a substring within a text. Uses character comparison, .equals(), and .contains().
2. Counting Coins (Greedy)
Making change (e.g., 37 = 25 + 10 + 2). The Greedy Approach always picks the largest possible coin first.
3. Knapsack Problem
Maximizing value without exceeding weight capacity. 0/1 Knapsack (take all or leave) vs Fractional (take parts).
4. Huffman Coding
Data compression. Builds a binary tree based on character frequency, assigning shorter binary codes (0/1) to common characters.
5. Activity Selection
Given tasks with Start/Finish times, find the maximum number of compatible (non-overlapping) activities. (Greedy by finish time).
6. Scheduling
Allocating tasks to resources based on Time, Priority, and Constraints to optimize throughput or minimize wait time.
Final Integrated Project: Student Management System ▼
Combine Arrays, Inheritance, Polymorphism, and Algorithms into one real-world application.
System Architecture
↑ (extends)
class Student (studentId, marks[], methods)
↓ (stored in)
Student[] students (Array of Objects)
Required Methods in Student Class
calculateTotal()
Iterates through the marks[] array to find the sum.
calculateAverage()
Divides total by the length of the marks array.
findGrade()
Uses if/else if logic based on the average.
displayStudent()
Polymorphic method overriding a parent display method.
Main Menu Operations (Algorithmic Logic)
- Add Students: Instantiate objects and store in the array.
- Search Student: Implement Linear Search by ID or Name.
- Sort Students: Use Bubble Sort to arrange the array by highest marks.
- Display Pass/Fail: Loop through the array and apply conditional logic.
Online ICT Classes in Sri Lanka – O/L, A/L, Cambridge, Edexcel, Python, Web Development & Digital Marketing
Island-wide online classes and home-visit classes in English, Sinhala (සිංහල) and Tamil (தமிழ்) – for school students, university students, BIT / BSc / IT final-year project students, beginners and business owners.
💬 WhatsApp Us Now ▶ Watch Free TutorialsWhat is ITClassSL? ITClassSL is a Sri Lankan ICT training service offering online and home-visit classes for G.C.E. O/L ICT, G.C.E. A/L ICT, Cambridge IGCSE / A Level, Pearson Edexcel, Python, Java, PHP & MySQL, web design, Microsoft Office, university and BIT final-year project guidance, and digital marketing. Classes run in English, Sinhala and Tamil, as individual or group sessions, anywhere in Sri Lanka. Contact: WhatsApp +94 72 962 2034 · itclasssl@gmail.com.
🚀 Learn Today. Build Tomorrow.
Looking for ICT classes in Sri Lanka, online ICT tuition, A/L ICT online class, computer classes near me or BIT project help? We provide practical, exam-focused and career-focused IT training with past papers, model papers, step-by-step coding and one-to-one support.
💡 Our ICT Training & Services in Sri Lanka
🏫 School ICT Classes (Grade 1 – 13)
Online and home-visit ICT lessons for Sri Lankan school students.
- G.C.E. O/L ICT (සාමාන්ය පෙළ ICT / சாதாரண தர ICT)
- G.C.E. A/L ICT (උසස් පෙළ ICT / உயர்தர ICT)
- GIT (General Information Technology)
- Term test papers, past papers & revision
🤖 Programming & AI
Learn to code from zero to project level.
- Python, C, Java, PHP, JavaScript
- HTML, CSS, jQuery & AJAX
- AI & machine-learning basics
- Problem solving & algorithms
🎓 University & Final-Year Project Guidance
Technical guidance for BIT, BSc, IT and ICT students.
- BIT / UCSC / UoM final-year projects
- PHP & MySQL, Python, Java projects
- Project ideas, proposal & documentation
- System design & database design
🌐 Web Design & Development
Websites and database-driven applications for individuals and businesses.
- Website design & development
- WordPress & Blogger
- PHP & MySQL web applications
- Website SEO & maintenance
📢 Digital Marketing
Grow your brand online in the Sri Lankan market.
- Facebook page & Facebook Ads
- Instagram, Reels, TikTok & YouTube
- SEO & content creation
- LinkedIn branding & campaign planning
💻 Computer & IT Skills
Essential computer skills from beginner to advanced.
- Computer fundamentals
- MS Word, Excel & PowerPoint
- Excel formulas & macros
- Oracle / MySQL / MS SQL, AWS, Linux
🗣️ English · සිංහල · தமிழ் – Classes in Your Language
English
Online ICT classes in Sri Lanka, A/L ICT online class, O/L ICT tuition, computer classes, Python classes, web design course, BIT project guidance, digital marketing course Sri Lanka, home visit ICT teacher, Cambridge & Edexcel ICT / Computer Science.
සිංහල
ශ්රී ලංකාවේ ඔන්ලයින් ICT පන්ති, උසස් පෙළ ICT ඔන්ලයින් පන්ති, සාමාන්ය පෙළ ICT පන්ති, පරිගණක පන්ති, පයිතන් (Python) ප්රෝග්රැමින් පන්ති, වෙබ් අඩවි නිර්මාණය, විශ්වවිද්යාල අවසන් වසර ව්යාපෘති මාර්ගෝපදේශනය, ඩිජිටල් මාකටින් පාඨමාලාව, නිවසට පැමිණ උගන්වන ICT ගුරුවරයා.
தமிழ்
இலங்கையில் ஆன்லைன் ICT வகுப்புகள், உயர்தர ICT ஆன்லைன் வகுப்பு, சாதாரண தர ICT வகுப்பு, கணினி வகுப்புகள், பைதான் (Python) நிரலாக்க வகுப்பு, இணையதள வடிவமைப்பு, பல்கலைக்கழக இறுதியாண்டு திட்ட வழிகாட்டல், டிஜிட்டல் மார்க்கெட்டிங் பயிற்சி, வீட்டிற்கு வந்து கற்பிக்கும் ICT ஆசிரியர்.
📚 Learn With Your Curriculum
Sri Lankan local syllabus, Pearson Edexcel and Cambridge programmes – ICT and Computer Science.
🇱🇰 Sri Lankan Local Curriculum
- Grade 1 – Grade 11 ICT
- G.C.E. O/L ICT · සා/පෙළ ICT · சா/த ICT
- G.C.E. A/L ICT · උ/පෙළ ICT · உ/த 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
- International A Level IT
- International A Level Computer Science
📗 Cambridge
- Cambridge Primary & 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 Classes
🎓 BIT, BSc & University Final-Year IT Project Guidance
🧑💻 Project Development
- BIT / BSc / IT / ICT projects
- PHP & MySQL projects
- Python & Java projects
- Web application & database projects
📄 Documentation & Practical
- Project ideas & proposals
- System architecture & database design
- Assignment guidance
- Technical documentation & viva preparation
🧠 AI & Smart Applications
- AI application concepts
- Machine-learning modules
- Automation applications
- Step-by-step coding support
📊 Database, Cloud & IT Professional Training
📱 Digital Marketing & Social Media Training (ඩිජිටල් මාකටින් · டிஜிட்டல் மார்க்கெட்டிங்)
🖥️ Microsoft Office & Digital Skills (පරිගණක පන්ති · கணினி வகுப்புகள்)
🧭 How to Join – 4 Simple Steps
- Message us on WhatsApp – tell us your grade / course, medium (English, Sinhala or Tamil) and your goal.
- Choose your format – online class (island-wide), home-visit class, individual or small group.
- Get your plan – schedule, syllabus coverage, notes, past papers or project roadmap.
- Start learning – live practical sessions with support between classes.
⭐ Why Join Our ICT Classes?
Study from anywhere in Sri Lanka or at home.
One-to-one or small group classes.
Learn in the medium you are comfortable with.
O/L, A/L, Cambridge, Edexcel, BIT, BSc.
Exam-focused practice and revision.
Build real programs, websites and projects.
❓ Frequently Asked Questions – ICT Classes in Sri Lanka
Do you conduct online ICT classes for O/L and A/L students in Sri Lanka?
Yes. We conduct online ICT classes for G.C.E. O/L and A/L students island-wide, and also offer home-visit individual classes. Classes cover the syllabus, past papers, model papers and revision.
Which languages are the classes taught in? (සිංහල / தமிழ் / English)
Classes are available in English, Sinhala and Tamil medium. / පන්ති ඉංග්රීසි, සිංහල සහ දෙමළ මාධ්යයෙන් පවතී. / வகுப்புகள் ஆங்கிலம், சிங்களம் மற்றும் தமிழ் மொழிகளில் நடைபெறும்.
Do you teach Cambridge and Pearson Edexcel ICT and Computer Science?
Yes. We support Cambridge Primary to A Level and Pearson Edexcel iPrimary to International A Level, including IGCSE ICT, IGCSE Computer Science and O Level Computer Science.
Can you help with BIT, BSc or IT final-year projects?
Yes. We give technical guidance on project ideas, system design, database design, PHP & MySQL, Python and Java development, and documentation for BIT, BSc, IT and ICT students.
Can I learn Python, PHP, web design or digital marketing as a complete beginner?
Yes. Courses start from absolute beginner level and move step by step to practical projects. No previous experience is needed.
What are the class fees and schedules?
Fees and timetables depend on the subject, grade and whether you choose individual or group classes. Message us on WhatsApp (+94 72 962 2034) for current details.
How can I contact ITClassSL?
WhatsApp or call +94 72 962 2034, email itclasssl@gmail.com, or message us on Facebook and the other platforms listed below.
📞 Ready to Start Learning?
Book your online ICT class or ask about programming courses, university project guidance and digital marketing training.
📱 Call / WhatsApp: +94 72 962 2034
📧 Email: itclasssl@gmail.com
💻 Skype: ITClassSL
💬 Contact Us on WhatsApp🌐 Our Online Learning Platforms
Tutorials, notes, project guides and learning resources.
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
Our training services 💻 eTeacher Website
Online learning platform 📝 Medium
Technology articles ❓ Quora
Project guidance and Q&A 🎓 Strikingly Portfolio
University project resources 🗣️ ElaKiri Forum
Project discussion 🎵 TikTok
Short learning videos 🛒 Payhip
Digital resources 🌐 Weebly
Project and IT resources