ICSE Class 10 Computer Applications - Full Theory Notes
ICSE Class 10 Computer Applications - Complete Theory Notes
---
## 1. Object-Oriented Programming (OOP) Concepts
**Definition:**
OOP is a programming paradigm based on the concept of "objects," which can contain data and
methods.
**Key Principles of OOP:**
1. **Class**: A blueprint or template for creating objects.
- Example: A "Car" class defines properties like color, model, and methods like start() or stop().
```java
class Car {
String color;
void start() {
System.out.println("Car started");
```
2. **Object**: An instance of a class.
- Example: `Car myCar = new Car();`
3. **Encapsulation**: Wrapping data and methods into a single unit and restricting direct access.
4. **Inheritance**: One class acquires the properties of another.
- Example: A "SportsCar" class can inherit from the "Car" class.
5. **Polymorphism**: A single function or method behaves differently based on the input.
- Example: Method overloading or overriding.
**Real-life Analogy:**
- Class: A blueprint of a house.
- Object: The actual house built using the blueprint.
---
## 2. Introduction to Java
**Key Features:**
1. Platform-independent: "Write Once, Run Anywhere" due to JVM.
2. Object-Oriented: Focus on classes and objects.
3. Secure: Built-in security features.
4. Robust: Handles runtime errors and supports garbage collection.
**Basic Java Structure:**
```java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
```
---
## 3. Values and Data Types
**Primitive Data Types:**
1. Integer: `int age = 10;`
2. Floating-point: `float price = 99.99f;`
3. Character: `char grade = 'A';`
4. Boolean: `boolean passed = true;`
**Non-Primitive Data Types:**
1. String: A sequence of characters.
```java
String name = "ICSE";
```
2. Arrays: Collection of similar data types.
**Type Casting:**
- Widening: Converting smaller to larger type (automatic).
- Narrowing: Converting larger to smaller type (explicit).
Example:
```java
int a = 10;
float b = a; // Widening
int c = (int) b; // Narrowing
```
---
## 4. Operators in Java
**Types of Operators:**
1. **Arithmetic Operators**: +, -, *, /, %.
2. **Relational Operators**: >, <, ==, !=.
3. **Logical Operators**: &&, ||, !.
**Example:**
```java
int a = 10, b = 20;
System.out.println(a + b); // Output: 30
System.out.println(a > b); // Output: false
```
---
## 5. Control Structures
### If-Else Statement
```java
if (marks > 40) {
System.out.println("Pass");
} else {
System.out.println("Fail");
```
### Switch-Case
```java
switch (day) {
case 1: System.out.println("Monday"); break;
case 2: System.out.println("Tuesday"); break;
default: System.out.println("Invalid");
```
---
## 6. Loops
**For Loop:**
```java
for (int i = 1; i <= 5; i++) {
System.out.println(i);
```
**While Loop:**
```java
int i = 1;
while (i <= 5) {
System.out.println(i);
i++;
```
**Do-While Loop:**
```java
int i = 1;
do {
System.out.println(i);
i++;
} while (i <= 5);
```
---
## 7. Arrays
**One-Dimensional Array:**
```java
int[] numbers = {10, 20, 30};
for (int i = 0; i < numbers.length; i++) {
System.out.println(numbers[i]);
```
**Key Operations:**
1. Traversal
2. Searching (Linear Search)
---
## 8. String Handling
**Methods:**
1. `length()`: Returns the length of the string.
2. `toUpperCase()`: Converts to uppercase.
3. `substring()`: Extracts a portion of the string.
Example:
```java
String name = "ICSE";
System.out.println(name.length()); // Output: 4
```
---
## 9. User-defined Methods
**Definition:** A reusable block of code.
**Syntax:**
```java
returnType methodName(parameters) {
// Code
```
**Example:**
```java
public static int add(int a, int b) {
return a + b;
```
---
## 10. File Handling
**Basic Operations:**
1. Writing to a file.
2. Reading from a file.
Example:
```java
FileWriter fw = new FileWriter("output.txt");
fw.write("Hello, World!");
fw.close();
```
---
## 11. Exception Handling
**Definition:** Handling runtime errors gracefully.
**Example:**
```java
try {
int result = 10 / 0;
} catch (ArithmeticException e) {
System.out.println("Cannot divide by zero");
```
---
## Tips for Scoring Full Marks:
1. Write clean, well-structured programs.
2. Always include comments in code.
3. Practice previous years' question papers.
4. Revise definitions, syntax, and sample programs.
---