Across all 5 subjects
Keep practicing!
Unlock more achievements
Total time spent
Loading...
Based on your progress and weak topics
Across all 5 subjects
Keep practicing!
Unlock more achievements
Total time spent
Based on your progress and weak topics
Master the concepts of test, measurement, assessment, and evaluation. Learn about test characteristics, construction, administration, and the current assessment system in Nepal.
Test: A test is a systematic procedure for measuring a sample of behavior. It is a tool or instrument used to measure students' knowledge, skills, abilities, or other characteristics. Tests can be written, oral, or practical and are designed to elicit responses that can be evaluated.
Measurement: Measurement is the process of assigning numbers or labels to objects, events, or characteristics according to specific rules. In education, measurement involves quantifying student performance, such as scores on a test. It answers the question "How much?" and provides quantitative data.
Assessment: Assessment is a broader concept that includes measurement but goes beyond it. It involves gathering, interpreting, and using information about student learning to make educational decisions. Assessment can be formal or informal and includes various methods like tests, observations, portfolios, and self-assessment.
Evaluation: Evaluation is the systematic process of determining the worth, value, or quality of educational programs, materials, or student performance. It involves making judgments based on criteria and standards. Evaluation answers questions like "How good?" "Is it effective?" and "What are the outcomes?"
| Aspect | Test | Measurement | Assessment | Evaluation |
|---|---|---|---|---|
| Focus | Instrument/Tool | Quantification | Process | Judgment |
| Question | What to use? | How much? | What to gather? | How good? |
| Scope | Narrow | Narrow | Broad | Broadest |
2.1 Diagnostic Evaluation:
2.2 Placement Evaluation:
2.3 Formative Evaluation:
2.4 Summative Evaluation:
| Feature | Formative Evaluation | Summative Evaluation |
|---|---|---|
| Timing | During instruction | End of instruction |
| Purpose | Improvement | Judgment/Grading |
| Feedback | Immediate and continuous | Delayed |
| Scope | Narrow (specific skills) | Broad (comprehensive) |
| Examples | Quizzes, class tests | Final exams, board exams |
1.1 Reliability:
Reliability refers to the consistency and stability of test scores. A reliable test produces consistent results when administered multiple times under similar conditions. It indicates the extent to which measurement is free from random errors.
Methods of Estimating Reliability:
a) Test-Retest Method:
b) Parallel Form Method (Alternate Form):
c) Split-Half Method:
Where r_half is the correlation between two halves
d) Kuder-Richardson Method (KR-20):
Where n = number of items, p = proportion correct, q = 1-p, ΟΒ² = variance
1.2 Validity:
Validity refers to the extent to which a test measures what it claims to measure. It is the most important quality of a test. A test may be reliable without being valid, but it cannot be valid without being reliable.
Types of Validity:
a) Content Validity:
b) Criterion Validity:
c) Construct Validity:
1.3 Objectivity:
Objectivity means that the test results are independent of the person scoring the test. Different scorers should arrive at the same scores when evaluating the same responses.
1.4 Usability:
Usability refers to the practical aspects of test administration and use:
A teacher-made test is an assessment instrument prepared by the classroom teacher to evaluate student learning in a specific subject or topic. Unlike standardized tests, teacher-made tests are tailored to the specific curriculum, teaching objectives, and student population of a particular classroom.
3.1 Subjective Test Items:
| Type | Description | Construction Tips | Uses |
|---|---|---|---|
| Essay Questions | Require extended written response | Specify scope, provide clear directions, use action verbs | Measure higher-order thinking, creativity |
| Short Answer | Brief responses (few words/sentences) | Make questions specific, avoid ambiguity | Test factual knowledge, definitions |
3.2 Objective Test Items:
| Type | Description | Construction Tips |
|---|---|---|
| Multiple Choice | Stem with 4-5 options, one correct | Make distractors plausible, avoid clues, one clearly correct answer |
| True-False | Statement to be judged true or false | Avoid absolute terms, equal true/false items |
| Matching | Two columns to be matched | Homogeneous items, clear directions, unequal numbers |
| Fill in the Blanks | Incomplete statements to complete | One clear answer, important content only |
| Level | Description | Action Verbs |
|---|---|---|
| Knowledge | Recall of specific information | Define, list, name, identify, recall |
| Comprehension | Understanding meaning | Explain, describe, summarize, paraphrase |
| Application | Use knowledge in new situations | Apply, solve, demonstrate, use |
| Analysis | Break down into components | Analyze, compare, contrast, differentiate |
| Synthesis | Combine elements to form new whole | Create, design, develop, formulate |
| Evaluation | Make judgments based on criteria | Evaluate, judge, justify, critique |
5.1 Planning the Test:
5.2 Preparing the Test:
Specification Chart Example:
| Content β Level β |
Unit 1 | Unit 2 | Unit 3 | Total |
|---|---|---|---|---|
| Knowledge | 2 | 2 | 1 | 5 |
| Comprehension | 2 | 3 | 2 | 7 |
| Application | 1 | 2 | 2 | 5 |
| Total | 5 | 7 | 5 | 17 |
Physical Conditions:
Administrative Conditions:
Objective Tests:
Subjective Tests:
3.1 Frequency Distribution:
A frequency distribution organizes raw data into classes/categories showing how often each value occurs.
3.2 Graphical Representation:
3.3 Measures of Central Tendency:
Where Ξ£X = sum of all scores, N = number of scores
For odd N: Median = Value at position (N+1)/2
For even N: Median = Average of values at positions N/2 and (N/2)+1
The score that occurs most frequently
3.4 Standard Deviation:
Standard deviation measures the spread or dispersion of scores around the mean.
Or using computational formula:
$$SD = \sqrt{\frac{\sum X^2}{N} - \left(\frac{\sum X}{N}\right)^2}$$Interpretation:
The school education system in Nepal has undergone significant changes in assessment practices:
Grading System (4.0 Scale):
| Percentage | Grade | Grade Point | Description |
|---|---|---|---|
| 90-100 | A+ | 4.0 | Outstanding |
| 80-89 | A | 3.6 | Excellent |
| 70-79 | B+ | 3.2 | Very Good |
| 60-69 | B | 2.8 | Good |
| 50-59 | C+ | 2.4 | Satisfactory |
| 40-49 | C | 2.0 | Acceptable |
| 35-39 | D | 1.6 | Basic |
| Below 35 | NG | 0 | Not Graded |
Adaptations and Accommodations:
Concept: Continuous Assessment System is an approach that involves regular, ongoing evaluation of student learning throughout the academic year, rather than relying solely on final examinations.
Process of CAS:
Components of CAS in Nepal:
| Challenges | Possible Solutions |
|---|---|
| Examination-centered education | Promote holistic assessment approaches |
| Lack of trained teachers in assessment | Provide professional development |
| Heavy workload for teachers | Use technology, reduce class size |
| Subjectivity in scoring | Develop rubrics, train scorers |
| Leakage of question papers | Improve security, use technology |
| Regional disparities | Equal resource distribution |
Master object-oriented programming with Java. Learn about data types, control structures, classes, inheritance, exception handling, multithreading, I/O, Swing, and JDBC.
Java was developed by James Gosling at Sun Microsystems in 1991, initially called "Oak" and later renamed to Java. The first public release was in 1995. Java's philosophy centers around "Write Once, Run Anywhere" (WORA), achieved through the Java Virtual Machine (JVM).
The JDK includes:
// HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Key Points:
Primitive Data Types:
| Type | Size | Range | Default |
|---|---|---|---|
| byte | 1 byte | -128 to 127 | 0 |
| short | 2 bytes | -32,768 to 32,767 | 0 |
| int | 4 bytes | -2^31 to 2^31-1 | 0 |
| long | 8 bytes | -2^63 to 2^63-1 | 0L |
| float | 4 bytes | Β±3.4E-38 to Β±3.4E+38 | 0.0f |
| double | 8 bytes | Β±1.7E-308 to Β±1.7E+308 | 0.0d |
| char | 2 bytes | 0 to 65,535 (Unicode) | '\u0000' |
| boolean | 1 bit | true or false | false |
| Category | Operators | Example |
|---|---|---|
| Arithmetic | + - * / % | a + b, a % b |
| Relational | == != < > <= >= | a == b, a > b |
| Logical | && || ! | a && b, !a |
| Assignment | = += -= *= /= %= | a = 5, a += 3 |
| Increment/Decrement | ++ -- | a++, --a |
| Bitwise | & | ^ ~ << >> | a & b, a << 2 |
| Ternary | ? : | (a > b) ? a : b |
If-Else Statement:
if (condition) {
// statements
} else if (anotherCondition) {
// statements
} else {
// statements
}
Switch Statement:
switch (expression) {
case value1:
// statements
break;
case value2:
// statements
break;
default:
// statements
}
Loops:
// For loop
for (int i = 0; i < 10; i++) {
System.out.println(i);
}
// While loop
while (condition) {
// statements
}
// Do-while loop
do {
// statements
} while (condition);
// Enhanced for loop (for-each)
for (int num : array) {
System.out.println(num);
}
Break and Continue:
// Declaration and initialization
int[] numbers = new int[5];
int[] marks = {85, 90, 78, 92, 88};
// 2D Array
int[][] matrix = new int[3][3];
int[][] grid = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
// Array length
int len = marks.length; // 5
// Enhanced for loop with arrays
for (int mark : marks) {
System.out.println(mark);
}
A class is a blueprint or template for creating objects. It defines the properties (fields/variables) and behaviors (methods) that objects of that class will have.
public class Student {
// Instance variables (fields)
private String name;
private int rollNumber;
private double marks;
// Class variable (shared by all objects)
static String collegeName = "TU";
// Constructor
public Student(String name, int rollNumber, double marks) {
this.name = name;
this.rollNumber = rollNumber;
this.marks = marks;
}
// Methods
public void displayInfo() {
System.out.println("Name: " + name);
System.out.println("Roll: " + rollNumber);
System.out.println("Marks: " + marks);
}
// Getters and Setters
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
// Creating objects
Student s1 = new Student("Ram", 101, 85.5);
Student s2 = new Student("Sita", 102, 90.0);
// Accessing methods
s1.displayInfo();
s2.setName("Gita");
String name = s2.getName();
public class Counter {
static int count = 0; // Class variable
Counter() {
count++; // Incremented for every object created
}
static void showCount() {
System.out.println("Count: " + count);
}
}
// Usage
Counter c1 = new Counter();
Counter c2 = new Counter();
Counter.showCount(); // Output: Count: 2
public class Box {
double width, height, depth;
// Default constructor
Box() {
width = height = depth = 0;
}
// Parameterized constructor
Box(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
// Copy constructor
Box(Box b) {
width = b.width;
height = b.height;
depth = b.depth;
}
double volume() {
return width * height * depth;
}
}
class Outer {
private int x = 10;
// Inner class
class Inner {
void display() {
System.out.println("x = " + x); // Can access outer class members
}
}
// Static nested class
static class StaticNested {
void show() {
System.out.println("Static nested class");
}
}
}
// Usage
Outer outer = new Outer();
Outer.Inner inner = outer.new Inner();
inner.display();
Outer.StaticNested nested = new Outer.StaticNested();
nested.show();
public class VarargsDemo {
// Method with variable arguments
static int sum(int... numbers) {
int total = 0;
for (int num : numbers) {
total += num;
}
return total;
}
public static void main(String[] args) {
System.out.println(sum(1, 2, 3)); // 6
System.out.println(sum(10, 20)); // 30
System.out.println(sum()); // 0
}
}
Inheritance is a mechanism where a new class (subclass/child) derives properties and behaviors from an existing class (superclass/parent). It promotes code reusability and establishes an "is-a" relationship.
// Parent/Super class
class Animal {
protected String name;
void eat() {
System.out.println(name + " is eating");
}
void sleep() {
System.out.println(name + " is sleeping");
}
}
// Child/Sub class
class Dog extends Animal {
void bark() {
System.out.println(name + " is barking");
}
}
// Usage
Dog dog = new Dog();
dog.name = "Buddy";
dog.eat(); // Inherited method
dog.bark(); // Own method
class Person {
String name;
Person(String name) {
this.name = name;
}
}
class Employee extends Person {
int salary;
Employee(String name, int salary) {
super(name); // Call parent constructor
this.salary = salary;
}
}
When a subclass provides a specific implementation of a method that is already defined in its parent class.
class Shape {
void draw() {
System.out.println("Drawing a shape");
}
}
class Circle extends Shape {
@Override
void draw() {
System.out.println("Drawing a circle");
}
}
Polymorphism means "many forms." In Java, it allows objects of different classes to be treated as objects of a common parent class.
// Runtime polymorphism
Shape s1 = new Circle();
Shape s2 = new Rectangle();
s1.draw(); // Calls Circle's draw()
s2.draw(); // Calls Rectangle's draw()
The method to be called is determined at runtime based on the actual object's type, not the reference type. This enables polymorphic behavior.
| Usage | Meaning | Example |
|---|---|---|
| final variable | Constant, cannot be changed | final int MAX = 100; |
| final method | Cannot be overridden | final void show() {} |
| final class | Cannot be extended | final class String {} |
abstract class Vehicle {
protected String brand;
// Abstract method
abstract void start();
// Concrete method
void stop() {
System.out.println("Vehicle stopped");
}
}
class Car extends Vehicle {
@Override
void start() {
System.out.println("Car starting with key");
}
}
| Modifier | Same Class | Same Package | Subclass | Everywhere |
|---|---|---|---|---|
| private | β | β | β | β |
| default | β | β | β | β |
| protected | β | β | β | β |
| public | β | β | β | β |
interface Drawable {
void draw(); // implicitly public abstract
double PI = 3.14159; // implicitly public static final
}
interface Resizable {
void resize(int percent);
}
class Rectangle implements Drawable, Resizable {
@Override
public void draw() {
System.out.println("Drawing rectangle");
}
@Override
public void resize(int percent) {
System.out.println("Resizing by " + percent + "%");
}
}
Exception handling provides a way to handle runtime errors gracefully without crashing the program.
try {
// Code that may throw exception
int result = 10 / 0;
} catch (ArithmeticException e) {
// Handle specific exception
System.out.println("Cannot divide by zero!");
} catch (Exception e) {
// Handle any other exception
System.out.println("An error occurred: " + e.getMessage());
} finally {
// Always executes
System.out.println("Finally block executed");
}
| Keyword | Purpose | Example |
|---|---|---|
| try | Encloses risky code | try { riskyCode(); } |
| catch | Handles exception | catch(Exception e) {} |
| finally | Always executes | finally { cleanup(); } |
| throw | Throws an exception | throw new Exception(); |
| throws | Declares exceptions | void method() throws IOException |
// Throwing an exception
void checkAge(int age) {
if (age < 18) {
throw new IllegalArgumentException("Age must be 18 or above");
}
}
// Re-throwing an exception
void method1() throws IOException {
try {
// Some I/O operation
} catch (IOException e) {
// Do some logging
throw e; // Re-throw the same exception
}
}
// Custom checked exception
class InsufficientBalanceException extends Exception {
public InsufficientBalanceException(String message) {
super(message);
}
}
// Custom unchecked exception
class InvalidInputException extends RuntimeException {
public InvalidInputException(String message) {
super(message);
}
}
// Usage
class BankAccount {
double balance;
void withdraw(double amount) throws InsufficientBalanceException {
if (amount > balance) {
throw new InsufficientBalanceException("Insufficient balance");
}
balance -= amount;
}
}
Multithreading allows concurrent execution of multiple threads (lightweight processes) within a single program.
Method 1: Extending Thread Class
class MyThread extends Thread {
@Override
public void run() {
for (int i = 1; i <= 5; i++) {
System.out.println(Thread.currentThread().getName() + ": " + i);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
// Usage
MyThread t1 = new MyThread();
MyThread t2 = new MyThread();
t1.start(); // Starts the thread, calls run()
t2.start();
Method 2: Implementing Runnable Interface
class MyRunnable implements Runnable {
@Override
public void run() {
for (int i = 1; i <= 5; i++) {
System.out.println(Thread.currentThread().getName() + ": " + i);
}
}
}
// Usage
Thread t1 = new Thread(new MyRunnable());
Thread t2 = new Thread(new MyRunnable(), "CustomThread");
t1.start();
t2.start();
| State | Description | Transition |
|---|---|---|
| NEW | Thread created, not started | start() β RUNNABLE |
| RUNNABLE | Ready to run or running | run() completes β TERMINATED |
| BLOCKED | Waiting for monitor lock | Lock available β RUNNABLE |
| WAITING | Waiting indefinitely | notify() β RUNNABLE |
| TIMED_WAITING | Waiting for specified time | Time expires β RUNNABLE |
| TERMINATED | Execution completed | - |
Synchronization prevents thread interference and memory consistency errors when multiple threads access shared data.
class Counter {
private int count = 0;
// Synchronized method
public synchronized void increment() {
count++;
}
// Synchronized block
public void decrement() {
synchronized(this) {
count--;
}
}
public int getCount() {
return count;
}
}
class SharedResource {
boolean flag = false;
synchronized void produce() throws InterruptedException {
while (flag) {
wait(); // Wait for consumption
}
// Produce data
flag = true;
notify(); // Notify consumer
}
synchronized void consume() throws InterruptedException {
while (!flag) {
wait(); // Wait for production
}
// Consume data
flag = false;
notify(); // Notify producer
}
}
// Using Scanner (most common)
import java.util.Scanner;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter name: ");
String name = scanner.nextLine();
System.out.print("Enter age: ");
int age = scanner.nextInt();
scanner.close();
// Using BufferedReader
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter text: ");
String text = br.readLine();
int num = Integer.parseInt(br.readLine());
import java.io.*;
// Writing to file
FileOutputStream fos = null;
try {
fos = new FileOutputStream("data.txt");
String data = "Hello, World!";
byte[] bytes = data.getBytes();
fos.write(bytes);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
// Reading from file (using try-with-resources)
try (FileInputStream fis = new FileInputStream("data.txt")) {
int data;
while ((data = fis.read()) != -1) {
System.out.print((char) data);
}
} catch (IOException e) {
e.printStackTrace();
}
// Writing with FileWriter
try (FileWriter fw = new FileWriter("text.txt")) {
fw.write("Hello from FileWriter!\n");
fw.write("Second line");
} catch (IOException e) {
e.printStackTrace();
}
// Reading with FileReader
try (FileReader fr = new FileReader("text.txt");
BufferedReader br = new BufferedReader(fr)) {
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
// Buffered writing
try (BufferedWriter bw = new BufferedWriter(new FileWriter("output.txt"))) {
for (int i = 1; i <= 1000; i++) {
bw.write("Line " + i);
bw.newLine();
}
} catch (IOException e) {
e.printStackTrace();
}
// Buffered reading
try (BufferedReader br = new BufferedReader(new FileReader("output.txt"))) {
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
RandomAccessFile allows reading from and writing to any position in a file.
try (RandomAccessFile raf = new RandomAccessFile("data.bin", "rw")) {
// Write data
raf.writeInt(100);
raf.writeDouble(3.14);
raf.writeUTF("Hello");
// Move to beginning
raf.seek(0);
// Read data
int num = raf.readInt();
double pi = raf.readDouble();
String str = raf.readUTF();
System.out.println(num + ", " + pi + ", " + str);
// Get current position
long pos = raf.getFilePointer();
// Get file length
long length = raf.length();
} catch (IOException e) {
e.printStackTrace();
}
import java.io.File;
File file = new File("test.txt");
// Check properties
System.out.println("Exists: " + file.exists());
System.out.println("Is file: " + file.isFile());
System.out.println("Is directory: " + file.isDirectory());
System.out.println("Length: " + file.length());
System.out.println("Path: " + file.getAbsolutePath());
// Create new file
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
// Create directory
File dir = new File("myFolder");
dir.mkdir();
// List directory contents
File[] files = dir.listFiles();
for (File f : files) {
System.out.println(f.getName());
}
// Delete file
file.delete();
Swing is a GUI (Graphical User Interface) toolkit for Java. It provides a rich set of components for building desktop applications.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FirstSwingApp {
public static void main(String[] args) {
// Create frame
JFrame frame = new JFrame("My First Swing App");
frame.setSize(400, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new FlowLayout());
// Create components
JLabel label = new JLabel("Enter your name:");
JTextField textField = new JTextField(20);
JButton button = new JButton("Click Me");
JTextArea textArea = new JTextArea(5, 30);
JCheckBox checkBox = new JCheckBox("I agree");
JRadioButton rb1 = new JRadioButton("Option 1");
JRadioButton rb2 = new JRadioButton("Option 2");
// Add action listener
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String name = textField.getText();
textArea.setText("Hello, " + name + "!");
}
});
// Add components to frame
frame.add(label);
frame.add(textField);
frame.add(button);
frame.add(textArea);
frame.add(checkBox);
frame.add(rb1);
frame.add(rb2);
// Display frame
frame.setVisible(true);
}
}
| Layout | Description | Use Case |
|---|---|---|
| FlowLayout | Components flow left to right, top to bottom | Simple arrangements |
| BorderLayout | 5 regions: NORTH, SOUTH, EAST, WEST, CENTER | Main window layout |
| GridLayout | Equal-sized cells in rows and columns | Calculator buttons |
| GridBagLayout | Flexible grid with constraints | Complex layouts |
// Method 1: Implementing Listener Interface
class MyFrame extends JFrame implements ActionListener {
JButton btn;
MyFrame() {
btn = new JButton("Click");
btn.addActionListener(this);
add(btn);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btn) {
JOptionPane.showMessageDialog(this, "Button clicked!");
}
}
}
// Method 2: Anonymous Inner Class
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Handle event
}
});
// Method 3: Lambda Expression (Java 8+)
button.addActionListener(e -> {
// Handle event
});
JDBC is a Java API for connecting and executing queries with databases.
import java.sql.*;
public class JDBCDemo {
public static void main(String[] args) {
// Database credentials
String url = "jdbc:mysql://localhost:3306/mydb";
String user = "root";
String password = "password";
try {
// Step 1: Load the driver
Class.forName("com.mysql.cj.jdbc.Driver");
// Step 2: Establish connection
Connection conn = DriverManager.getConnection(url, user, password);
// Step 3: Create statement
Statement stmt = conn.createStatement();
// Step 4: Execute query (CREATE)
String createSQL = "CREATE TABLE IF NOT EXISTS students " +
"(id INT PRIMARY KEY, name VARCHAR(50), marks DOUBLE)";
stmt.executeUpdate(createSQL);
// Step 4: Execute query (INSERT)
String insertSQL = "INSERT INTO students VALUES (1, 'Ram', 85.5)";
int rows = stmt.executeUpdate(insertSQL);
System.out.println(rows + " row(s) inserted");
// Step 4: Execute query (SELECT)
String selectSQL = "SELECT * FROM students";
ResultSet rs = stmt.executeQuery(selectSQL);
// Step 5: Process results
while (rs.next()) {
int id = rs.getInt("id");
String name = rs.getString("name");
double marks = rs.getDouble("marks");
System.out.println(id + " | " + name + " | " + marks);
}
// Step 6: Close resources
rs.close();
stmt.close();
conn.close();
} catch (ClassNotFoundException e) {
System.out.println("Driver not found: " + e.getMessage());
} catch (SQLException e) {
System.out.println("Database error: " + e.getMessage());
}
}
}
// Using PreparedStatement (prevents SQL injection)
String sql = "INSERT INTO students VALUES (?, ?, ?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
// Set parameters
pstmt.setInt(1, 2);
pstmt.setString(2, "Sita");
pstmt.setDouble(3, 90.0);
// Execute
pstmt.executeUpdate();
// Reuse with different values
pstmt.setInt(1, 3);
pstmt.setString(2, "Hari");
pstmt.setDouble(3, 78.5);
pstmt.executeUpdate();
pstmt.close();
public class StudentDAO {
private Connection conn;
public StudentDAO() throws SQLException {
String url = "jdbc:mysql://localhost:3306/school";
conn = DriverManager.getConnection(url, "root", "password");
}
// CREATE
public void addStudent(int id, String name, double marks) throws SQLException {
String sql = "INSERT INTO students VALUES (?, ?, ?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
pstmt.setString(2, name);
pstmt.setDouble(3, marks);
pstmt.executeUpdate();
pstmt.close();
}
// READ
public void getAllStudents() throws SQLException {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM students");
while (rs.next()) {
System.out.println(rs.getInt(1) + " - " + rs.getString(2));
}
rs.close();
stmt.close();
}
// UPDATE
public void updateMarks(int id, double newMarks) throws SQLException {
String sql = "UPDATE students SET marks = ? WHERE id = ?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, newMarks);
pstmt.setInt(2, id);
pstmt.executeUpdate();
pstmt.close();
}
// DELETE
public void deleteStudent(int id) throws SQLException {
String sql = "DELETE FROM students WHERE id = ?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
pstmt.executeUpdate();
pstmt.close();
}
}
Understand computer networks, protocols, Internet architecture, and network technologies. Learn about OSI model, TCP/IP, routing, subnetting, and wireless networks.
The Internet is a global network of interconnected computer networks that use standardized communication protocols (TCP/IP) to link devices worldwide. It evolved from ARPANET (1969) to the modern global network we use today.
Access Networks:
| Type | Technology | Speed | Use Case |
|---|---|---|---|
| DSL | Digital Subscriber Line | Up to 100 Mbps | Home internet |
| Cable | DOCSIS over coaxial | Up to 1 Gbps | Home internet |
| FTTH | Fiber to the Home | Up to 10 Gbps | High-speed home |
| WiFi | 802.11 wireless | Up to 9.6 Gbps | Wireless LAN |
| 4G/5G | Cellular networks | Up to 10 Gbps | Mobile internet |
Physical Media:
| Aspect | Packet Switching | Circuit Switching |
|---|---|---|
| Resource Allocation | On-demand, shared | Dedicated, reserved |
| Data Transmission | Data divided into packets | Continuous bit stream |
| Setup | No setup required | Call setup needed |
| Efficiency | Better for bursty traffic | Better for steady traffic |
| Examples | Internet, Ethernet | Traditional telephone |
Types of Delay:
Throughput: Rate at which bits are transferred between sender and receiver. Bottlenecked by the slowest link in the path.
OSI Model (7 Layers):
| Layer | Name | Function | Protocols/Examples |
|---|---|---|---|
| 7 | Application | Network applications | HTTP, FTP, SMTP, DNS |
| 6 | Presentation | Data representation, encryption | SSL, JPEG, ASCII |
| 5 | Session | Session management | NetBIOS, RPC |
| 4 | Transport | End-to-end delivery | TCP, UDP |
| 3 | Network | Routing, logical addressing | IP, ICMP, OSPF |
| 2 | Data Link | Node-to-node delivery | Ethernet, PPP, ARP |
| 1 | Physical | Bit transmission | Cables, Hubs, Repeaters |
Encapsulation: Each layer adds its own header (and sometimes trailer) to the data from upper layer.
Data flow: Application β Transport β Network β Data Link β Physical β Transmission
HTTP is the foundation of data communication on the World Wide Web. It is a request-response protocol between client and server.
HTTP Versions:
HTTP Request Message Format:
GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html
Connection: close
(body - for POST requests)
HTTP Response Message Format:
HTTP/1.1 200 OK
Date: Mon, 01 Jan 2024 12:00:00 GMT
Server: Apache/2.4
Content-Type: text/html
Content-Length: 1234
(body containing HTML)
HTTP Status Codes:
| Code | Meaning | Examples |
|---|---|---|
| 1xx | Informational | 100 Continue |
| 2xx | Success | 200 OK, 201 Created |
| 3xx | Redirection | 301 Moved, 304 Not Modified |
| 4xx | Client Error | 400 Bad Request, 404 Not Found |
| 5xx | Server Error | 500 Internal Error, 503 Unavailable |
DNS translates human-readable domain names (like www.google.com) to IP addresses (like 142.250.80.46).
DNS Query Types:
DNS Record Types:
| Type | Purpose | Example |
|---|---|---|
| A | IPv4 address | www.example.com β 93.184.216.34 |
| AAAA | IPv6 address | www.example.com β 2606:2800:220:1:248:1893:25c8:1946 |
| CNAME | Canonical name (alias) | www.example.com β example.com |
| MX | Mail exchange | example.com β mail.example.com |
| NS | Name server | example.com β ns1.example.com |
SMTP (Simple Mail Transfer Protocol):
POP3 (Post Office Protocol v3):
IMAP (Internet Message Access Protocol):
In P2P networks, peers act as both clients and servers, sharing resources directly without a central server.
BitTorrent Protocol:
Client-Server: $$D_{cs} = max\left(\frac{NF}{u_s}, \frac{F}{d_{min}}\right)$$
P2P: $$D_{P2P} = max\left(\frac{F}{u_s}, \frac{F}{d_{min}}, \frac{NF}{u_s + \sum u_i}\right)$$
Where F = file size, N = peers, u_s = server upload rate, d_min = minimum download rate
The transport layer provides logical communication between application processes running on different hosts. It segments data from application layer and reassembles it at the destination.
UDP is a connectionless, unreliable transport protocol with minimal overhead.
UDP Segment Structure:
| Field | Size | Description |
|---|---|---|
| Source Port | 16 bits | Sender's port number |
| Destination Port | 16 bits | Receiver's port number |
| Length | 16 bits | Total segment length in bytes |
| Checksum | 16 bits | Error detection |
UDP Characteristics:
UDP Applications: DNS, streaming multimedia, online gaming, VoIP
TCP is a connection-oriented, reliable transport protocol that provides guaranteed delivery, in-order delivery, and flow/congestion control.
TCP Segment Structure:
| Field | Size | Description |
|---|---|---|
| Source Port | 16 bits | Sender's port |
| Destination Port | 16 bits | Receiver's port |
| Sequence Number | 32 bits | Byte stream position |
| Acknowledgment Number | 32 bits | Expected next sequence number |
| Flags (SYN, ACK, FIN, etc.) | 6 bits | Control flags |
| Receive Window | 16 bits | Flow control (buffer space) |
| Checksum | 16 bits | Error detection |
TCP connection is established through a three-step process:
Four-way handshake for connection termination:
Mechanisms:
Receiver advertises available buffer space (rwnd) in TCP header. Sender ensures:
Congestion Window (cwnd): Limits sender's transmission rate based on network congestion.
AIMD (Additive Increase Multiplicative Decrease):
| Feature | TCP | UDP |
|---|---|---|
| Connection | Connection-oriented | Connectionless |
| Reliability | Reliable (guaranteed delivery) | Unreliable |
| Ordering | In-order delivery | No ordering |
| Header Size | 20-60 bytes | 8 bytes |
| Flow Control | Yes | No |
| Congestion Control | Yes | No |
| Speed | Slower | Faster |
The network layer is responsible for delivering packets from source host to destination host. It has two main components:
Router Components:
IPv4 addresses are 32-bit identifiers assigned to network interfaces.
Address Classes (Historical):
| Class | First Bits | Range | Default Mask | Networks | Hosts/Net |
|---|---|---|---|---|---|
| A | 0 | 1.0.0.0 - 126.255.255.255 | /8 (255.0.0.0) | 126 | 16,777,214 |
| B | 10 | 128.0.0.0 - 191.255.255.255 | /16 (255.255.0.0) | 16,384 | 65,534 |
| C | 110 | 192.0.0.0 - 223.255.255.255 | /24 (255.255.255.0) | 2,097,152 | 254 |
Subnetting divides a network into smaller subnetworks by borrowing bits from the host portion.
Subnetting Example:
Network: 192.168.1.0/24, need 4 subnets
CIDR eliminates class boundaries, allowing flexible allocation of address space using prefix notation (e.g., /20).
CIDR Aggregation Example:
NAT allows multiple devices on a private network to share a single public IP address.
Private IP Address Ranges:
NAT Types:
IPv6 uses 128-bit addresses, providing approximately 3.4 Γ 10^38 addresses.
IPv6 Address Format:
IPv6 Address Types:
| Type | Prefix | Purpose |
|---|---|---|
| Unicast | Various | One-to-one communication |
| Multicast | FF00::/8 | One-to-many communication |
| Anycast | Any unicast | One-to-nearest communication |
Link-State (LS) Routing - Dijkstra's Algorithm:
Distance-Vector (DV) Routing - Bellman-Ford:
Where d_x(y) = cost of least-cost path from x to y
| Protocol | Type | Algorithm | Metric | Use Case |
|---|---|---|---|---|
| RIP | IGP | Distance Vector | Hop count (max 15) | Small networks |
| OSPF | IGP | Link State | Bandwidth | Large enterprise |
| BGP | EGP | Path Vector | Policy-based | Internet routing |
ICMP is used for error reporting and diagnostic functions.
Common ICMP Types:
| Type | Code | Meaning |
|---|---|---|
| 0 | 0 | Echo Reply (ping reply) |
| 3 | 0-15 | Destination Unreachable |
| 8 | 0 | Echo Request (ping) |
| 11 | 0-1 | Time Exceeded (TTL=0) |
Parity Checks:
Checksum:
CRC (Cyclic Redundancy Check):
Channel Partitioning:
Random Access:
Ethernet is the dominant wired LAN technology.
Ethernet Frame Structure:
| Field | Size | Description |
|---|---|---|
| Preamble | 7 bytes | Synchronization |
| SFD | 1 byte | Start Frame Delimiter |
| Destination MAC | 6 bytes | Receiver's address |
| Source MAC | 6 bytes | Sender's address |
| Type/Length | 2 bytes | Protocol type or length |
| Data | 46-1500 bytes | Payload |
| FCS (CRC) | 4 bytes | Frame Check Sequence |
MAC Address:
ARP maps IP addresses to MAC addresses on the same network.
ARP Process:
VLANs logically segment a physical network into multiple broadcast domains.
VLAN Benefits:
VLAN Tagging (802.1Q):
802.11 Standards:
| Standard | Frequency | Max Speed | Range |
|---|---|---|---|
| 802.11b | 2.4 GHz | 11 Mbps | ~50m |
| 802.11a | 5 GHz | 54 Mbps | ~30m |
| 802.11g | 2.4 GHz | 54 Mbps | ~50m |
| 802.11n | 2.4/5 GHz | 600 Mbps | ~70m |
| 802.11ac | 5 GHz | 3.5 Gbps | ~35m |
| 802.11ax (WiFi 6) | 2.4/5 GHz | 9.6 Gbps | ~70m |
Wireless networks use CSMA/CA instead of CSMA/CD because collision detection is difficult in wireless.
CSMA/CA Process:
Cellular Generations:
| Generation | Technology | Speed | Features |
|---|---|---|---|
| 1G | Analog | - | Voice only |
| 2G | GSM/CDMA | ~64 kbps | Digital voice, SMS |
| 3G | UMTS/HSPA | ~2 Mbps | Mobile internet |
| 4G LTE | OFDM | ~100 Mbps | HD video, VoLTE |
| 5G | NR (New Radio) | ~10 Gbps | IoT, low latency, massive connectivity |
Learn software development processes, requirements engineering, design patterns, testing strategies, and project management techniques for successful software delivery.
Software Engineering is the application of a systematic, disciplined, quantifiable approach to the development, operation, and maintenance of software. (IEEE Definition)
| Aspect | Programming | Software Engineering |
|---|---|---|
| Scope | Writing code | Entire software lifecycle |
| Focus | Individual | Team, process, quality |
| Documentation | Minimal | Comprehensive |
| Maintenance | Often neglected | Planned and managed |
Attributes of Good Software:
ACM/IEEE Code of Ethics:
| Type | Description | Examples |
|---|---|---|
| Embedded | Software in hardware devices | Microwave, car ECU |
| Information Systems | Data processing systems | ERP, CRM, banking |
| Sensor-based | Data collection systems | Weather monitoring |
| Support Environment | Development tools | IDE, version control |
Waterfall Model:
Incremental Model:
Spiral Model:
V-Model:
Agile Manifesto Values:
Agile Principles:
Scrum Roles:
Scrum Artifacts:
Scrum Events:
Functional Requirements:
Non-Functional Requirements:
| Category | Description | Example |
|---|---|---|
| Performance | Speed, throughput | Response time < 2 seconds |
| Security | Protection, authentication | Passwords encrypted |
| Reliability | Availability, MTBF | 99.9% uptime |
| Usability | Ease of use | Training time < 1 hour |
| Scalability | Handle growth | Support 10,000 users |
Use Case Components:
Use Case Template:
Context Models:
Interaction Models:
Structural Models:
Behavioral Models:
Layered Architecture:
Client-Server Architecture:
Model-View-Controller (MVC):
Microservices Architecture:
Development Testing:
Release Testing:
User Testing:
TDD Cycle:
Software evolution is the process of changing software after delivery to correct faults, improve performance, or adapt to changed environment.
Lehman's Laws of Software Evolution:
Legacy systems are older systems that are still in use but rely on obsolete technology.
Legacy System Strategies:
Types of Maintenance:
| Type | Description | % of Effort |
|---|---|---|
| Corrective | Fix defects | ~20% |
| Adaptive | Adapt to environment changes | ~25% |
| Perfective | Add new features, improve | ~50% |
| Preventive | Prevent future problems | ~5% |
Project Scheduling:
Gantt Charts:
COCOMO Model (Constructive Cost Model):
Basic COCOMO formula:
Where KLOC = Thousands of Lines of Code
| Project Type | a | b | c | d |
|---|---|---|---|---|
| Organic | 2.4 | 1.05 | 2.5 | 0.38 |
| Semi-detached | 3.0 | 1.12 | 2.5 | 0.35 |
| Embedded | 3.6 | 1.20 | 2.5 | 0.32 |
Risk Management Process:
Risk Strategies:
Quality Attributes:
Quality Assurance Activities:
Master combinatorics, mathematical induction, Boolean algebra, cryptography, functions, sorting algorithms, and finite state automata for computer science foundations.
Product Rule: If there are m ways to do one thing and n ways to do another, there are m Γ n ways to do both.
Example: 3 shirts and 4 pants β 3 Γ 4 = 12 outfits
Sum Rule: If there are m ways to do one thing and n ways to do another, and they cannot be done together, there are m + n ways to do either.
Example: 5 CS courses or 4 Math courses β 5 + 4 = 9 choices
Number of ways to arrange r items from n distinct items
Number of ways to choose r items from n distinct items
Example: How many ways to choose 3 students from 10?
$$C(10,3) = \frac{10!}{3! \times 7!} = \frac{10 \times 9 \times 8}{3 \times 2 \times 1} = 120$$
If n items are put into m containers, with n > m, then at least one container must contain more than one item.
Generalized Pigeonhole Principle: If n items are put into m containers, then at least one container must contain at least βn/mβ items.
Example: In a group of 13 people, at least 2 share the same birth month.
The binomial coefficient $\binom{n}{r}$ appears in the expansion of $(a + b)^n$.
Pascal's Identity:
$$\binom{n}{r} = \binom{n-1}{r-1} + \binom{n-1}{r}$$For two sets:
$$|A \cup B| = |A| + |B| - |A \cap B|$$For three sets:
$$|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |B \cap C| - |A \cap C| + |A \cap B \cap C|$$Mathematical induction is a proof technique used to prove statements about all natural numbers.
Steps:
Example: Prove 1 + 2 + 3 + ... + n = n(n+1)/2
In strong induction, we assume the statement is true for all values from base case up to k.
Example: Every integer n > 1 is either prime or product of primes
A recurrence relation defines a sequence where each term is a function of previous terms.
Example - Fibonacci:
$$F(n) = F(n-1) + F(n-2), \quad F(0) = 0, F(1) = 1$$Homogeneous Linear Recurrence with Constant Coefficients:
$$a_n = c_1 a_{n-1} + c_2 a_{n-2} + ... + c_k a_{n-k}$$Characteristic Equation:
$$r^k - c_1 r^{k-1} - c_2 r^{k-2} - ... - c_k = 0$$Example: Solve a_n = 5a_{n-1} - 6a_{n-2} with a_0 = 1, a_1 = 4
The generating function for a sequence {a_n} is:
$$G(x) = \sum_{n=0}^{\infty} a_n x^n$$Useful Generating Functions:
Boolean algebra operates on two values: 0 (false) and 1 (true).
Basic Operations:
| Operation | Symbol | Description |
|---|---|---|
| AND | Β· or β§ | 1 if both inputs are 1 |
| OR | + or β¨ | 1 if at least one input is 1 |
| NOT | Β― or ' | Inverts the input |
| Law | Expression |
|---|---|
| Identity | A + 0 = A, A Β· 1 = A |
| Null | A + 1 = 1, A Β· 0 = 0 |
| Idempotent | A + A = A, A Β· A = A |
| Complement | A + A' = 1, A Β· A' = 0 |
| Commutative | A + B = B + A, A Β· B = B Β· A |
| Associative | A + (B + C) = (A + B) + C |
| Distributive | A Β· (B + C) = AΒ·B + AΒ·C |
| De Morgan's | (A + B)' = A' Β· B', (A Β· B)' = A' + B' |
Sum of Products (SOP):
OR of AND terms. Example: F = A'B + AB'
Product of Sums (POS):
AND of OR terms. Example: F = (A + B)(A' + B')
K-maps provide a visual method for simplifying Boolean expressions.
2-Variable K-map:
B'B B
A'A | 0 | 1 |
A | 2 | 3 |
Simplification Rules:
a β‘ b (mod m) means a - b is divisible by m, or a and b have the same remainder when divided by m.
Euclidean Algorithm for GCD:
gcd(a, b) = gcd(b, a mod b)
gcd(a, 0) = a
Extended Euclidean Algorithm: Finds integers x and y such that ax + by = gcd(a,b)
Caesar Cipher:
Substitution Cipher:
Transposition Cipher:
Symmetric (Private-Key) Cryptography:
Asymmetric (Public-Key) Cryptography:
Key Generation:
Encryption/Decryption:
p = 3, q = 11
n = 33, Ο(n) = 20
e = 3 (gcd(3,20) = 1)
d = 7 (since 3Γ7 = 21 β‘ 1 mod 20)
Encrypt m = 5: c = 5Β³ mod 33 = 125 mod 33 = 26
Decrypt c = 26: m = 26β· mod 33 = 5
Hash functions map arbitrary-length input to fixed-length output.
Properties:
Common Hash Functions: MD5 (broken), SHA-1 (deprecated), SHA-256
Types of Relations:
Function Types:
Floor and Ceiling:
Hashing Functions:
| Algorithm | Best | Average | Worst | Space | Stable |
|---|---|---|---|---|---|
| Bubble Sort | O(n) | O(nΒ²) | O(nΒ²) | O(1) | Yes |
| Selection Sort | O(nΒ²) | O(nΒ²) | O(nΒ²) | O(1) | No |
| Insertion Sort | O(n) | O(nΒ²) | O(nΒ²) | O(1) | Yes |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | Yes |
| Quick Sort | O(n log n) | O(n log n) | O(nΒ²) | O(log n) | No |
| Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) | No |
A grammar G = (V, T, P, S) where:
Chomsky Hierarchy:
| Type | Grammar | Automaton | Rule Form |
|---|---|---|---|
| 0 | Unrestricted | Turing Machine | Ξ± β Ξ² (any) |
| 1 | Context-Sensitive | Linear Bounded | Ξ±AΞ² β Ξ±Ξ³Ξ² |
| 2 | Context-Free | Pushdown Automaton | A β Ξ³ |
| 3 | Regular | Finite Automaton | A β aB or A β a |
Components:
Deterministic Finite Automaton (DFA):
Nondeterministic Finite Automaton (NFA):
Mealy Machine: Output depends on state and input
Moore Machine: Output depends only on state
Turing machines are the most powerful computational model, equivalent to any digital computer.
Components:
Church-Turing Thesis: Any effectively computable function can be computed by a Turing machine.