Programming in Java

Unit 2: Data Types, Variables & Wrapper Classes

From primitive bytes to wrapper magic โ€” master every data type, variable scope, type casting, and wrapper class method that powers real Java applications.

โฑ๏ธ 5 hrs theory + 4 hrs lab  |  ๐Ÿ’ฐ Earning Potential: โ‚น5Kโ€“โ‚น15K/month  |  ๐Ÿ“ 30 MCQs (Bloom's Mapped)

๐Ÿ’ผ Jobs this unlocks: Jr Java Developer (โ‚น4โ€“6 LPA)  |  Backend Intern (โ‚น3โ€“5 LPA)  |  Freelance Java Projects

Section A

Opening Hook โ€” The Data Behind Every Rupee

๐Ÿ’ณ How Paytm Handles โ‚น1,00,000 Crore in Digital Payments

Open your Paytm app right now. See that wallet balance โ€” say โ‚น2,347.50? Internally, Paytm stores it as a double: double balance = 2347.50;. When you tap "Pay โ‚น50 for chai," the backend calls Double.toString(balance) to display it on screen, and Integer.parseInt(inputAmount) to validate your input. When Paytm checks your phone number length? That's "9876543210".length() returning an int. When it verifies your PIN? Each digit is a char, validated as a boolean.

Every single rupee you see, send, or receive on Paytm went through Java data types. The wallet balance is a double. The transaction ID is a long. The "Payment Successful" flag is a boolean. The UPI PIN is an array of char. And when Paytm wraps these primitives into objects for network transmission? That's Wrapper Classes โ€” Integer, Double, Character, Boolean.

What if YOU built this? What if you understood exactly how Java stores, converts, wraps, and validates every piece of data in a โ‚น1 lakh crore fintech system? That's exactly what this chapter teaches you.

๐Ÿ‡ฎ๐Ÿ‡ณ Paytm๐Ÿ‡ฎ๐Ÿ‡ณ PhonePe๐Ÿ‡ฎ๐Ÿ‡ณ Razorpay๐Ÿ‡ฎ๐Ÿ‡ณ CRED๐Ÿ‡ฎ๐Ÿ‡ณ Zerodha๐Ÿ‡ฎ๐Ÿ‡ณ Flipkart
Java processes over 3 billion UPI transactions per month in India. Every UPI app โ€” PhonePe, Google Pay, Paytm โ€” runs Java microservices on the backend. The entire NPCI (National Payments Corporation of India) infrastructure uses Java. Learning Java data types isn't academic โ€” it's the foundation of India's โ‚น20 lakh crore digital payments ecosystem.
Section B

Learning Outcomes โ€” Bloom's Taxonomy Mapped (12 Outcomes)

Bloom's LevelLearning Outcome
๐Ÿ”ต RememberList all 8 primitive data types with their sizes, default values, and ranges
๐Ÿ”ต RememberRecall all 53 reserved keywords in Java and identify valid/invalid identifiers
๐Ÿ”ต UnderstandExplain the difference between widening (implicit) and narrowing (explicit) type conversion with examples
๐Ÿ”ต UnderstandDescribe the three types of variables โ€” local, instance, and static โ€” and their scopes
๐ŸŸข ApplyWrite Java programs using type casting to convert between primitive types correctly
๐ŸŸข ApplyUse Wrapper classes (Integer, Double, Character, Boolean) for autoboxing, unboxing, parsing, and conversion
๐ŸŸข AnalyzeCompare access modifiers (public, private, protected, default) and determine appropriate usage in class design
๐ŸŸข AnalyzeDifferentiate between primitive types and their Wrapper class counterparts in terms of memory, nullability, and use in Collections
๐ŸŸ  EvaluateAssess when to use int vs long vs BigInteger for Indian financial calculations (Aadhaar numbers, transaction IDs)
๐ŸŸ  EvaluateEvaluate the 5 uses of the static keyword and justify when each is appropriate
๐ŸŸ  CreateDesign and build a multi-currency converter application using proper data types, type casting, and wrapper class methods
๐ŸŸ  CreateConstruct a type-safe Java utility class demonstrating all variable scopes, access modifiers, and static members
Section C

Concept Explanation โ€” Data Types, Variables & Wrapper Classes from Scratch

1. The 8 Primitive Data Types

Java is a strongly typed language โ€” every variable must have a declared type before you use it. Think of data types as different-sized containers in your kitchen. You don't store rice in a teacup (too small) or water in a thali (wrong shape). Similarly, Java gives you exactly 8 primitive "containers," each designed for a specific kind of data.

๐Ÿ“ฆ Complete Primitive Type Reference Table

TypeSizeDefaultRangeExampleUse Case
byte1 byte (8 bits)0-128 to 127byte age = 25;Small numbers, file I/O, network data
short2 bytes (16 bits)0-32,768 to 32,767short pincode = 11001;Pincode prefix, port numbers
int4 bytes (32 bits)0-2ยณยน to 2ยณยน-1 (~ยฑ2.1 billion)int salary = 500000;Most integer math, loop counters, array indices
long8 bytes (64 bits)0L-2โถยณ to 2โถยณ-1long aadhaar = 123456789012L;Aadhaar numbers, timestamps, large IDs
float4 bytes (32 bits)0.0fยฑ3.4 ร— 10ยณโธ (~7 decimal digits)float pi = 3.14f;Graphics, game coordinates, approx. math
double8 bytes (64 bits)0.0dยฑ1.7 ร— 10ยณโฐโธ (~15 decimal digits)double balance = 2347.50;Financial calculations, scientific computing
char2 bytes (16 bits)'\u0000'0 to 65,535 (Unicode)char grade = 'A';Single characters, Unicode symbols, โ‚น sign
boolean~1 bit (JVM-dependent)falsetrue or falseboolean isPaid = true;Flags, conditions, toggles
Why does Aadhaar need long? An Aadhaar number is 12 digits (e.g., 999912345678). The max value of int is ~2.1 billion (10 digits). So int simply cannot hold an Aadhaar number! You must use long. This is a real interview question at TCS and Infosys.
Java
// Real-world data types in action โ€” Paytm-style payment record
byte paymentMode = 2;              // 1=UPI, 2=Wallet, 3=Card
short bankCode = 1234;             // IFSC prefix number
int transactionAmount = 500;       // โ‚น500 payment
long txnId = 20260623143052001L;   // Unique transaction ID
float cashbackPercent = 2.5f;      // 2.5% cashback
double walletBalance = 2347.50;    // Precise wallet balance
char currency = 'โ‚น';               // Indian Rupee symbol (Unicode)
boolean isSuccess = true;          // Payment successful?
Students write float pi = 3.14; โ€” this is a compile error! In Java, decimal literals are double by default. You must suffix with f: float pi = 3.14f;. Similarly, long literals need the L suffix: long x = 999999999999L;. Forgetting these suffixes is the #1 exam mistake.

2. Type Conversion โ€” Widening & Narrowing

Sometimes you need to store a value of one type into a variable of another type. Java handles this in two ways:

๐Ÿ”„ Widening Conversion (Implicit / Automatic)

Analogy: Pouring water from a small glass into a big bucket โ€” no spill, no risk. Java does this automatically because no data is lost.

Direction: byte โ†’ short โ†’ int โ†’ long โ†’ float โ†’ double

Also: char โ†’ int

Java
int salary = 500000;
double doubleSalary = salary;   // Automatic: int โ†’ double
System.out.println(doubleSalary); // 500000.0

char ch = 'A';
int ascii = ch;                  // Automatic: char โ†’ int
System.out.println(ascii);       // 65

๐Ÿ”ป Narrowing Conversion (Explicit / Manual Casting)

Analogy: Pouring water from a bucket into a glass โ€” it might overflow! You must do this consciously, acknowledging the risk of data loss.

Direction: double โ†’ float โ†’ long โ†’ int โ†’ short โ†’ byte

Syntax: (targetType) value

Java
double price = 999.99;
int roundedPrice = (int) price;   // Explicit cast: double โ†’ int
System.out.println(roundedPrice);  // 999 (decimal part LOST!)

int bigNumber = 130;
byte small = (byte) bigNumber;    // Explicit cast: int โ†’ byte
System.out.println(small);         // -126 (overflow!)
In interviews, they love asking: "What happens when you cast (byte) 130?" Answer: byte range is -128 to 127. 130 overflows โ†’ wraps around โ†’ result is -126. The formula is: 130 - 256 = -126. This is called modular arithmetic.

3. All 53 Java Keywords

Keywords are reserved words that Java has claimed for its own syntax. You cannot use them as variable names, class names, or method names. Think of them as "government-reserved land" โ€” you can't build your house on it.

๐Ÿ”‘ Complete Java Keywords Table (53 Keywords)

CategoryKeywords
Data Types (8)byte short int long float double char boolean
Flow Control (12)if else switch case default for while do break continue return yield
Access Modifiers (3)public private protected
Class/Object (8)class interface extends implements new this super instanceof
Modifiers (7)static final abstract synchronized volatile transient native
Package (2)package import
Exception (6)try catch finally throw throws assert
Misc (5)void enum strictfp const* goto*
Literals (2)true false null (technically literals, not keywords, but reserved)

* const and goto are reserved but not used in Java. They exist to prevent C/C++ programmers from using them accidentally.

Java has 53 keywords but C has only 32 and Python has 35. Java's higher count reflects its emphasis on access control, exception handling, and OOP. In exams, const and goto are trick-question favorites โ€” they ARE reserved keywords but have NO functionality in Java.

Identifiers & Naming Conventions

An identifier is any name you give to a class, method, variable, or label. Rules:

  • Can contain letters (A-Z, a-z), digits (0-9), underscore (_), and dollar sign ($)
  • Cannot start with a digit
  • Cannot be a keyword
  • Case-sensitive: salary โ‰  Salary โ‰  SALARY
ConventionStyleExample
Class namesPascalCasePaytmWallet, StudentRecord
Method namescamelCasecalculateInterest(), getBalance()
Variable namescamelCasewalletBalance, userName
ConstantsUPPER_SNAKE_CASEMAX_RETRY, GST_RATE
Packagesall lowercasecom.paytm.payments

4. Variables โ€” Local, Instance & Static

A variable is a named memory location that holds a value. Java has three types of variables, each with different scope (where it's visible) and lifetime (how long it exists).

๐Ÿ“ Three Types of Variables

TypeDeclared InScopeDefault ValueLifetime
LocalInside a method/blockOnly within that method/blockโŒ None (must initialise)Method execution
InstanceInside a class, outside methodsEntire class (per object)โœ… Type default (0, false, null)Object lifetime
Static (Class)Inside a class with staticEntire class (shared by all objects)โœ… Type defaultProgram lifetime
Java
public class PaytmAccount {
    // Instance variable โ€” each user has their own
    double balance = 0.0;
    String userName;

    // Static variable โ€” shared across ALL accounts
    static int totalAccounts = 0;
    static final double GST_RATE = 0.18;

    public void deposit(double amount) {
        // Local variable โ€” exists only inside this method
        double gst = amount * GST_RATE;
        double net = amount - gst;
        balance += net;
        System.out.println("Deposited โ‚น" + net);
    }
}
Using a local variable without initialising it causes a compile-time error. Unlike instance and static variables (which get defaults), local variables have NO default. int x; System.out.println(x); โ†’ Error! Always assign a value: int x = 0;

5. Access Modifiers โ€” public, private, protected, default

Access modifiers control who can see and use your classes, methods, and variables. Think of them as security levels at an office building:

๐Ÿ” Access Modifier Comparison Table

ModifierSame ClassSame PackageSubclass (other pkg)Other PackageAnalogy
publicโœ…โœ…โœ…โœ…Open gate โ€” anyone can enter
protectedโœ…โœ…โœ…โŒFamily WhatsApp group โ€” relatives only
default (no keyword)โœ…โœ…โŒโŒColony gate โ€” neighbours only
privateโœ…โŒโŒโŒBedroom lock โ€” only you
Java
public class BankAccount {
    public String bankName = "SBI";            // Anyone can see
    protected String branch = "Connaught Place"; // Same package + subclasses
    String ifscCode = "SBIN0001234";            // Default โ€” same package only
    private double balance = 50000.0;           // Only this class

    public double getBalance() {               // Getter โ€” controlled access
        return balance;
    }
}
Interview favourite: "Why make fields private and provide public getters/setters?" Answer: Encapsulation โ€” you control what values are set. A setBalance() method can validate that the amount isn't negative. Direct field access can't.

6. The static Keyword โ€” 5 Uses

The static keyword means "belongs to the class, not to any specific object." Think of it as a college notice board โ€” it belongs to the college (class), not to any individual student (object).

โšก 5 Uses of static in Java

#UseSyntaxExample
1Static Variablestatic int count;Shared counter across all objects
2Static Methodstatic void display()Math.sqrt(), Integer.parseInt()
3Static Blockstatic { ... }Initialise static variables when class loads
4Static Nested Classstatic class Inner { }Utility helper classes inside a parent
5Static Importimport static java.lang.Math.*;Use sqrt(25) instead of Math.sqrt(25)
Java
public class RazorpayTransaction {
    static int totalTransactions = 0;  // 1. Static variable

    static {                              // 3. Static block โ€” runs once when class loads
        System.out.println("Razorpay SDK initialized");
    }

    String orderId;
    double amount;

    RazorpayTransaction(String id, double amt) {
        this.orderId = id;
        this.amount = amt;
        totalTransactions++;              // Shared across all objects
    }

    static int getTotalTransactions() {  // 2. Static method
        return totalTransactions;
    }
}

7. Wrapper Classes โ€” Integer, Double, Character, Boolean

The Big Bazaar Analogy: You buy a gift โ€” say a nice pen. The pen itself is the primitive value. But if you're giving it as a Diwali gift, you wrap it in a decorative box with a ribbon. The wrapper makes it presentable, giftable, and "object-like." That's exactly what Wrapper classes do โ€” they wrap primitive values into objects.

Wrapper = gift wrapping at Big Bazaar. The pen (primitive int) is the same, but the gift box (Integer object) lets you pass it around, add it to collections, and give it a null state (empty box). Without the wrapper, you can't put a primitive into an ArrayList, HashMap, or any Java Collection.

๐ŸŽ Primitive โ†’ Wrapper Mapping

PrimitiveWrapper ClassParse MethodvalueOf MethodtoString Method
byteByteByte.parseByte("10")Byte.valueOf((byte)10)Byte.toString((byte)10)
shortShortShort.parseShort("100")Short.valueOf((short)100)Short.toString((short)100)
intIntegerInteger.parseInt("500")Integer.valueOf(500)Integer.toString(500)
longLongLong.parseLong("99999")Long.valueOf(99999L)Long.toString(99999L)
floatFloatFloat.parseFloat("3.14")Float.valueOf(3.14f)Float.toString(3.14f)
doubleDoubleDouble.parseDouble("99.9")Double.valueOf(99.9)Double.toString(99.9)
charCharacterโ€”Character.valueOf('A')Character.toString('A')
booleanBooleanBoolean.parseBoolean("true")Boolean.valueOf(true)Boolean.toString(true)

Autoboxing & Unboxing (Java 5+)

Autoboxing = Java automatically wraps a primitive into its Wrapper object.
Unboxing = Java automatically unwraps a Wrapper object back to its primitive.

Java
// AUTOBOXING: primitive โ†’ Wrapper (automatic)
int amount = 500;
Integer wrappedAmount = amount;   // int โ†’ Integer (autoboxing)

// UNBOXING: Wrapper โ†’ primitive (automatic)
Integer price = Integer.valueOf(999);
int rawPrice = price;             // Integer โ†’ int (unboxing)

// PARSING: String โ†’ primitive
String userInput = "1500";
int rupees = Integer.parseInt(userInput);  // String โ†’ int

// TOSTRING: primitive โ†’ String
double balance = 2347.50;
String display = Double.toString(balance);  // double โ†’ String "2347.5"

// Using Wrappers in Collections
ArrayList<Integer> cart = new ArrayList<>();
cart.add(299);   // autoboxing: int โ†’ Integer
cart.add(599);
int first = cart.get(0);  // unboxing: Integer โ†’ int
Integer.parseInt("12.5") throws NumberFormatException! The parseInt method only accepts whole number strings. For decimals, use Double.parseDouble("12.5"). This is a very common runtime error in student projects.
Integer.valueOf() vs Integer.parseInt(): Both parse strings, but parseInt() returns a primitive int, while valueOf() returns an Integer object. In most cases, use parseInt() for primitives and valueOf() when you need an object (e.g., for Collections).

Important Wrapper Class Utility Methods

Java
// Integer utilities
System.out.println(Integer.MAX_VALUE);   // 2147483647
System.out.println(Integer.MIN_VALUE);   // -2147483648
System.out.println(Integer.toBinaryString(10));  // "1010"
System.out.println(Integer.toHexString(255));    // "ff"
System.out.println(Integer.toOctalString(8));    // "10"

// Character utilities
System.out.println(Character.isDigit('9'));       // true
System.out.println(Character.isLetter('A'));      // true
System.out.println(Character.toUpperCase('a'));   // 'A'
System.out.println(Character.isWhitespace(' '));  // true

// Boolean utilities
System.out.println(Boolean.parseBoolean("true"));   // true
System.out.println(Boolean.parseBoolean("yes"));    // false (only "true" works)
Section D

Learn by Doing โ€” 3-Tier Lab: Currency Converter INR โ†” USD/EUR/GBP

๐ŸŸข Tier 1 โ€” GUIDED: Basic INR โ†’ USD Converter

โฑ๏ธ 30โ€“45 minutesBeginnerZero prior knowledge assumed

Step 1: Create the file CurrencyConverter.java

Java
import java.util.Scanner;

public class CurrencyConverter {
    // Static constants โ€” exchange rates (as of June 2026)
    static final double USD_RATE = 83.50;  // 1 USD = โ‚น83.50
    static final double EUR_RATE = 91.20;  // 1 EUR = โ‚น91.20
    static final double GBP_RATE = 106.75; // 1 GBP = โ‚น106.75

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

        System.out.println("=== INR Currency Converter ===");
        System.out.print("Enter amount in INR: โ‚น");

        // Parse user input using Wrapper class method
        String input = sc.nextLine();
        double inr = Double.parseDouble(input);

        // Type conversion: double โ†’ int (narrowing)
        int roundedINR = (int) inr;

        // Calculate conversions
        double usd = inr / USD_RATE;
        double eur = inr / EUR_RATE;
        double gbp = inr / GBP_RATE;

        // Display using Wrapper toString()
        System.out.println("\n--- Conversion Results ---");
        System.out.println("โ‚น" + Double.toString(inr) + " = $"
            + String.format("%.2f", usd) + " USD");
        System.out.println("โ‚น" + roundedINR + " = โ‚ฌ"
            + String.format("%.2f", eur) + " EUR");
        System.out.println("โ‚น" + roundedINR + " = ยฃ"
            + String.format("%.2f", gbp) + " GBP");

        // Boolean check
        boolean isLargeAmount = inr > 100000;
        System.out.println("Large transaction: " +
            Boolean.toString(isLargeAmount));

        sc.close();
    }
}

Step 2: Compile & Run

Terminal
javac CurrencyConverter.java
java CurrencyConverter

Expected Output:

=== INR Currency Converter === Enter amount in INR: โ‚น5000 --- Conversion Results --- โ‚น5000.0 = $59.88 USD โ‚น5000 = โ‚ฌ54.82 EUR โ‚น5000 = ยฃ46.84 GBP Large transaction: false

๐ŸŽ‰ Congratulations! You've used all 4 Wrapper classes (Double.parseDouble, Double.toString, Boolean.toString, Integer via casting), type conversion, static constants, and local variables โ€” all in one real program!

๐ŸŸก Tier 2 โ€” SEMI-GUIDED: Two-way Converter with Menu

โฑ๏ธ 60โ€“90 minutesIntermediateHints provided, you fill the gaps

Your Mission:

Extend the Tier 1 converter to support both directions (INRโ†’Foreign AND Foreignโ†’INR) with a menu system.

Requirements:

  1. Display a menu: 1. INR โ†’ USD | 2. INR โ†’ EUR | 3. INR โ†’ GBP | 4. USD โ†’ INR | 5. EUR โ†’ INR | 6. GBP โ†’ INR
  2. Use Integer.parseInt() to read the menu choice
  3. Use a switch statement with char cases or int cases
  4. Add input validation: if user enters non-numeric input, catch NumberFormatException
  5. Display results using String.format("%.2f")
  6. Use static methods for each conversion (e.g., static double inrToUsd(double inr))

Hints:

Java
// Hint 1: Parse menu choice
int choice = Integer.parseInt(sc.nextLine());

// Hint 2: Static conversion methods
static double inrToUsd(double inr) {
    return inr / USD_RATE;
}

// Hint 3: Error handling
try {
    double amount = Double.parseDouble(input);
} catch (NumberFormatException e) {
    System.out.println("Invalid input! Enter a number.");
}
Stretch Goal: Add a loop so the user can convert multiple amounts without restarting the program. Use boolean continueLoop = true; and ask "Convert again? (y/n)".

๐Ÿ”ด Tier 3 โ€” OPEN CHALLENGE: Full-featured Currency Converter Widget

โฑ๏ธ 2โ€“3 hoursAdvancedNo instructions โ€” real-world mini-project

The Brief:

Build a production-quality currency converter application with these features:

  1. CurrencyRate class with instance variables for currency code (String), rate (double), symbol (char)
  2. Static counter tracking total conversions performed
  3. Support 5+ currencies: INR, USD, EUR, GBP, JPY, AED
  4. Type validation: Use Character.isDigit() and Integer.parseInt() for all inputs
  5. Wrapper class usage: Store conversion history in ArrayList<Double>
  6. Access modifiers: Private rates, public methods, protected utility methods
  7. Display conversion history at the end with total, average, min, max amounts

Deliverable: A clean, well-commented Java program demonstrating every concept from this chapter.

This exact project can be showcased on your GitHub. Currency converters are a common interview coding challenge. Polish it well, add a README.md, and it becomes a portfolio piece. Recruiters at TCS, Infosys, and Wipro regularly check GitHub profiles of freshers.
Section E

Problem Set โ€” Syntax, Programming, Industry & Interview Questions

Syntax Questions (5)

  1. Identify and fix the error: float temperature = 36.6;
  2. What is the output? System.out.println((int) 99.99);
  3. Identify and fix the error: int 2ndPlace = 2;
  4. What is the output? char ch = 'A'; System.out.println(ch + 1);
  5. Will this compile? byte b = 128; โ€” Explain why or why not.

Programming Questions (8)

  1. Write a Java program to find the size of all 8 primitive data types using their Wrapper class constants (e.g., Integer.SIZE, Byte.SIZE).
  2. Write a program that accepts a temperature in Fahrenheit (as a String), converts it to Celsius using Double.parseDouble(), and displays the result rounded to 2 decimal places.
  3. Create a program that demonstrates widening conversion for all paths: byte โ†’ short โ†’ int โ†’ long โ†’ float โ†’ double.
  4. Write a program that takes a character input and prints whether it is a digit, letter, uppercase, lowercase, or whitespace using Character class methods.
  5. Build a simple GST Calculator: input price as String, parse to double, calculate 18% GST, display base price, GST amount, and total.
  6. Write a program that demonstrates the difference between Integer.parseInt() and Integer.valueOf() by showing their return types.
  7. Create a program with a class Student having: private instance variables (name, rollNo), a static variable (college name), and a static method to display total students.
  8. Write a program that converts an integer to binary, octal, and hexadecimal using Integer wrapper methods.

Industry Questions (3)

  1. Paytm Scenario: Paytm stores wallet balance as double. Why not float? Calculate the precision difference when storing โ‚น99,99,999.99 in both types.
  2. Aadhaar Scenario: UIDAI stores Aadhaar numbers. A junior developer used int. Explain why this fails and what type should be used. What about leading zeros โ€” should it be a String?
  3. Razorpay Scenario: Razorpay processes payments in paise (โ‚น500.00 = 50000 paise) to avoid floating-point errors. Discuss why int in paise is better than double in rupees for financial applications.

Interview Questions (3)

  1. TCS favourite: What is the difference between autoboxing and unboxing? Give an example where autoboxing can cause a NullPointerException.
  2. Infosys favourite: Can we call a non-static method from a static method? Why or why not? How would you solve this?
  3. Wipro favourite: Explain the output: Integer a = 127; Integer b = 127; System.out.println(a == b); and Integer c = 128; Integer d = 128; System.out.println(c == d);
The Integer cache question (#3) is asked in 70% of Java interviews. Java caches Integer objects from -128 to 127. So a == b is true (same cached object), but c == d is false (different objects on heap). Always use .equals() for Wrapper comparisons!
Section F

MCQ Assessment Bank โ€” 30 Questions (Bloom's Mapped)

Remember / Identify (Q1โ€“Q5)

Q1

Which of the following is NOT a primitive data type in Java?

  1. int
  2. boolean
  3. String
  4. char
Remember
โœ… Answer: (C) String โ€” String is a class (reference type), not a primitive. Java has exactly 8 primitive types: byte, short, int, long, float, double, char, boolean.
Q2

The size of int in Java is:

  1. 2 bytes
  2. 4 bytes
  3. 8 bytes
  4. Depends on platform
Remember
โœ… Answer: (B) 4 bytes โ€” Unlike C/C++, Java's int is always 4 bytes (32 bits) on every platform. This is part of Java's "Write Once, Run Anywhere" guarantee.
Q3

The default value of a boolean instance variable is:

  1. true
  2. 0
  3. false
  4. null
Remember
โœ… Answer: (C) false โ€” Boolean instance variables default to false. Local booleans have no default (must be initialised).
Q4

Which keyword is reserved in Java but not currently used?

  1. abstract
  2. goto
  3. static
  4. final
Remember
โœ… Answer: (B) goto โ€” Both goto and const are reserved keywords in Java but have no functionality. They exist to prevent C/C++ programmers from using them accidentally.
Q5

The Wrapper class for int is:

  1. Int
  2. INTEGER
  3. Integer
  4. int_wrapper
Remember
โœ… Answer: (C) Integer โ€” The wrapper class names match the primitive names but capitalised: intโ†’Integer, charโ†’Character, booleanโ†’Boolean. Note: intโ†’Integer (not Int), charโ†’Character (not Char).

Understand / Explain (Q6โ€“Q10)

Q6

What is widening conversion?

  1. Converting an object to a primitive
  2. Converting a smaller primitive type to a larger one automatically
  3. Converting a String to an integer
  4. Converting a larger type to a smaller one
Understand
โœ… Answer: (B) โ€” Widening (implicit) conversion automatically converts a smaller type to a larger one (e.g., int โ†’ double) without data loss. No explicit cast needed.
Q7

Why does Java require an explicit cast for narrowing conversion?

  1. It's a syntax rule with no practical reason
  2. To improve program speed
  3. Because data loss may occur when converting from a larger to smaller type
  4. Because Java doesn't support narrowing
Understand
โœ… Answer: (C) โ€” Narrowing can cause data loss (e.g., (int) 99.99 loses the decimal part). Java forces an explicit cast so the programmer acknowledges this risk.
Q8

What is autoboxing in Java?

  1. Manually creating Wrapper objects using constructors
  2. Automatic conversion of a primitive to its corresponding Wrapper class object
  3. Converting a String to a primitive
  4. Using boxing gloves in a Java program
Understand
โœ… Answer: (B) โ€” Autoboxing (Java 5+) automatically converts primitives to Wrapper objects. Example: Integer x = 5; โ€” Java auto-converts int 5 to Integer.valueOf(5).
Q9

A local variable in Java:

  1. Gets a default value of 0
  2. Must be initialised before use
  3. Is shared across all methods
  4. Can be accessed from other classes
Understand
โœ… Answer: (B) โ€” Local variables have NO default value. Using an uninitialised local variable causes a compile-time error. Instance and static variables get defaults.
Q10

What does the static keyword mean for a variable?

  1. The variable cannot be changed
  2. The variable belongs to the class, not to any specific object
  3. The variable is private
  4. The variable is stored on the stack
Understand
โœ… Answer: (B) โ€” A static variable belongs to the class itself and is shared among all instances. Only one copy exists regardless of how many objects are created.

Apply / Use (Q11โ€“Q15)

Q11

What is the output of: System.out.println((int) 3.9 + (int) 4.1);

  1. 8
  2. 7
  3. 8.0
  4. 7.0
Apply
โœ… Answer: (B) 7 โ€” (int) 3.9 = 3 (truncated, not rounded). (int) 4.1 = 4. So 3 + 4 = 7.
Q12

What does Integer.parseInt("100") return?

  1. The String "100"
  2. An Integer object with value 100
  3. The primitive int value 100
  4. A compilation error
Apply
โœ… Answer: (C) โ€” parseInt() returns a primitive int. Use Integer.valueOf("100") to get an Integer object.
Q13

Which statement correctly declares a long variable for an Aadhaar number?

  1. long aadhaar = 123456789012;
  2. long aadhaar = 123456789012L;
  3. int aadhaar = 123456789012;
  4. Long aadhaar = "123456789012";
Apply
โœ… Answer: (B) โ€” Large literal integers need the L suffix. Without it, Java treats the literal as int (which overflows for 12-digit numbers). Option A causes a compile error.
Q14

What is the output of: System.out.println(Character.isDigit('โ‚น'));

  1. true
  2. false
  3. Compilation error
  4. Runtime error
Apply
โœ… Answer: (B) false โ€” 'โ‚น' is the Indian Rupee Unicode symbol, not a digit. Character.isDigit() returns true only for '0'โ€“'9' and equivalent Unicode digits.
Q15

What is the output of: byte b = (byte) 130; and System.out.println(b);

  1. 130
  2. -126
  3. 127
  4. Compilation error
Apply
โœ… Answer: (B) -126 โ€” byte range is -128 to 127. Casting 130 to byte: 130 - 256 = -126 (modular arithmetic / overflow wrap-around).

Analyze / Compare (Q16โ€“Q20)

Q16

What is the key difference between private and default (no modifier) access?

  1. No difference โ€” they're the same
  2. private is accessible within same class only; default is accessible within same package
  3. private is accessible within same package; default is class-only
  4. default makes the member public in subclasses
Analyze
โœ… Answer: (B) โ€” private restricts access to the declaring class only. Default (package-private) allows access from any class in the same package.
Q17

When should you use double instead of float?

  1. When you need to save memory
  2. When you need higher precision (more decimal digits)
  3. When dealing with boolean values
  4. When working with Unicode characters
Analyze
โœ… Answer: (B) โ€” double provides ~15 decimal digits of precision vs float's ~7 digits. For financial calculations (e.g., bank balances), double is essential to avoid rounding errors.
Q18

Compare: Integer.parseInt("50") vs Integer.valueOf("50")

  1. Both return the same type
  2. parseInt returns int; valueOf returns Integer
  3. parseInt returns Integer; valueOf returns int
  4. They cannot parse the same input
Analyze
โœ… Answer: (B) โ€” parseInt() returns a primitive int. valueOf() returns an Integer object. Use parseInt when you need a primitive, valueOf when you need an object (e.g., for Collections).
Q19

What is the difference between a local variable and an instance variable?

  1. Local variables are global; instance variables are local
  2. Local variables exist within a method and have no default; instance variables belong to an object and have defaults
  3. Instance variables must be static
  4. Local variables can only be int
Analyze
โœ… Answer: (B) โ€” Local variables are method-scoped with no default value. Instance variables are object-scoped, stored on the heap, and get default values (0, false, null).
Q20

Why can't primitives be stored directly in an ArrayList?

  1. ArrayList doesn't support numbers
  2. Generics in Java work only with reference types (objects), not primitives
  3. Primitives are too slow for ArrayLists
  4. You need to use arrays instead
Analyze
โœ… Answer: (B) โ€” Java generics use type erasure, which requires reference types. ArrayList<int> is invalid; you must use ArrayList<Integer>. Autoboxing handles the conversion automatically.

Evaluate / Justify (Q21โ€“Q25)

Q21

A banking application stores account balances. Which approach is BEST?

  1. float balance
  2. double balance
  3. int balanceInPaise (store paise, not rupees)
  4. String balance
Evaluate
โœ… Answer: (C) โ€” Storing amounts in paise as int avoids floating-point precision errors. โ‚น999.99 becomes 99999 paise. This is how Razorpay and Stripe handle payments internally. double (B) is acceptable for display but not for calculations.
Q22

When is using static methods appropriate?

  1. When the method needs to access instance variables
  2. When the method performs a utility operation that doesn't depend on object state
  3. When we want the method to be slow
  4. When we need to create multiple objects
Evaluate
โœ… Answer: (B) โ€” Static methods are ideal for utility/helper functions like Math.sqrt(), Integer.parseInt(), and Arrays.sort(). They don't need object state, so creating an instance would be wasteful.
Q23

Evaluate: "We should always use Wrapper classes instead of primitives for better OOP design."

  1. True โ€” OOP requires objects everywhere
  2. False โ€” Wrappers use more memory and are slower; use primitives when objects aren't needed
  3. True โ€” primitives are deprecated
  4. False โ€” Wrappers don't exist in modern Java
Evaluate
โœ… Answer: (B) โ€” Each Wrapper object adds ~16 bytes of overhead vs 4 bytes for an int. In performance-critical code (loops, arrays), primitives are 2โ€“3x faster. Use Wrappers only when needed (Collections, nullability, API requirements).
Q24

A developer writes protected methods in a utility class. Is this a good practice?

  1. Yes โ€” protected is always the safest choice
  2. No โ€” utility classes should use public static methods and a private constructor to prevent instantiation
  3. Yes โ€” it ensures backward compatibility
  4. No โ€” utility classes should use default access
Evaluate
โœ… Answer: (B) โ€” Utility classes (like Math, Arrays, Collections) follow the pattern: public static methods + private constructor. protected is designed for inheritance hierarchies, not utility classes.
Q25

Why does Integer a = 127; Integer b = 127; (a == b) return true, but Integer c = 128; Integer d = 128; (c == d) return false?

  1. Java is buggy for numbers above 127
  2. Java caches Integer objects from -128 to 127; values outside this range create new objects on the heap
  3. == always compares values for Wrapper types
  4. 128 is not a valid Integer value
Evaluate
โœ… Answer: (B) โ€” Java maintains an internal cache (IntegerCache) for Integer values -128 to 127. Values within this range return the same cached object (so == compares the same reference). Values outside create new heap objects. Always use .equals() for Wrapper comparisons.

Create / Design (Q26โ€“Q30)

Q26

You're designing a Student class. Which declaration is most appropriate for a student's phone number?

  1. int phone = 9876543210;
  2. long phone = 9876543210L;
  3. String phone = "9876543210";
  4. double phone = 9876543210.0;
Create
โœ… Answer: (C) String โ€” Phone numbers can have leading zeros (e.g., +91-09876543210), aren't used for arithmetic, and int overflows for 10-digit Indian numbers. long (B) works technically but loses leading zeros. String is the industry standard.
Q27

Design a Product class for an e-commerce app. Which fields should be static?

  1. productName, price
  2. gstRate, totalProductsCreated
  3. productId, category
  4. description, imageUrl
Create
โœ… Answer: (B) โ€” gstRate (18% GST applies to all products equally) and totalProductsCreated (a class-level counter) are shared across all instances. Per-product fields like name, price, and ID should be instance variables.
Q28

You need to store 1 million integers for a data processing task. Which approach is best?

  1. ArrayList<Integer>
  2. int[] array = new int[1000000];
  3. long[] array = new long[1000000];
  4. ArrayList<String> with parsed values
Create
โœ… Answer: (B) โ€” A primitive int[] uses ~4 MB (4 bytes ร— 1M). An ArrayList<Integer> uses ~20 MB (each Integer object has ~16 bytes overhead + 4 bytes pointer). For large datasets, primitive arrays are 5x more memory-efficient.
Q29

You're building a configuration class. How should you declare a constant for maximum login attempts?

  1. int maxAttempts = 3;
  2. public static final int MAX_LOGIN_ATTEMPTS = 3;
  3. private static int MAX_ATTEMPTS = 3;
  4. final int attempts = 3;
Create
โœ… Answer: (B) โ€” Constants should be public (accessible), static (class-level, not per-object), and final (unchangeable). Naming convention: UPPER_SNAKE_CASE.
Q30

Design a method signature for a currency converter that takes INR amount (as String from user input) and returns USD value. What is the best signature?

  1. public void convert(int amount)
  2. public static double convertInrToUsd(String inrInput) throws NumberFormatException
  3. private String convert(double amount)
  4. protected static int convertCurrency(float amount)
Create
โœ… Answer: (B) โ€” public (accessible), static (utility method, no object state needed), double return (precise USD value), String input (raw user input needs parsing), throws NumberFormatException (handles invalid input). This is clean, production-quality API design.
Section G

Short Answer Questions (8 Questions)

SA-1: List all 8 primitive data types in Java with their sizes.

Answer: Java's 8 primitives are: byte (1 byte), short (2 bytes), int (4 bytes), long (8 bytes), float (4 bytes), double (8 bytes), char (2 bytes), boolean (~1 bit, JVM-dependent). These are not objects โ€” they are stored directly on the stack (for local variables) or within the object on the heap (for instance variables).

SA-2: What is the difference between widening and narrowing type conversion?

Answer: Widening (Implicit) converts a smaller type to a larger type automatically without data loss: int x = 5; double d = x; (int โ†’ double). Narrowing (Explicit) converts a larger type to a smaller type manually, risking data loss: double d = 9.99; int x = (int) d; (double โ†’ int, decimal lost). Narrowing requires an explicit cast operator (type).

SA-3: What is autoboxing and unboxing? Give one example of each.

Answer: Autoboxing = automatic conversion of primitive โ†’ Wrapper: Integer obj = 42; (Java converts int 42 to Integer.valueOf(42)). Unboxing = automatic conversion of Wrapper โ†’ primitive: int x = obj; (Java converts Integer back to int). These features were introduced in Java 5 to reduce boilerplate code when working with Collections.

SA-4: Explain the scope difference between local, instance, and static variables.

Answer: Local โ€” declared inside a method, exists only during method execution, must be initialised manually. Instance โ€” declared in class but outside methods, unique to each object, gets default values, exists as long as the object exists. Static โ€” declared with static, shared across all objects of the class, exists for the entire program lifetime, belongs to the class not objects.

SA-5: Compare public, private, protected, and default access modifiers.

Answer: public โ€” accessible everywhere (any class, any package). protected โ€” accessible in same package + subclasses in other packages. default (no keyword) โ€” accessible only within the same package. private โ€” accessible only within the declaring class. Order of increasing restriction: public โ†’ protected โ†’ default โ†’ private.

SA-6: What are the 5 uses of the static keyword in Java?

Answer: (1) Static variable โ€” shared class-level variable. (2) Static method โ€” can be called without creating an object (e.g., Math.sqrt()). (3) Static block โ€” runs once when class is loaded, used for initialisation. (4) Static nested class โ€” inner class that doesn't need outer class instance. (5) Static import โ€” import static members directly (e.g., import static java.lang.Math.*;).

SA-7: What is the difference between Integer.parseInt() and Integer.valueOf()?

Answer: parseInt("100") returns a primitive int value 100. valueOf("100") returns an Integer object with value 100. Additionally, valueOf() uses the Integer cache (-128 to 127), making it more memory-efficient for small values. Use parseInt() when you need a primitive; use valueOf() when you need an object.

SA-8: Why can't you write ArrayList<int> in Java? How do you solve this?

Answer: Java generics use type erasure at compile time, which works only with reference types (objects), not primitives. int is a primitive, not an object. The solution is to use the Wrapper class: ArrayList<Integer>. Java's autoboxing automatically converts int values to Integer objects when adding to the list.

Section H

Long Answer Questions (3 Questions)

LA-1: Explain all 8 primitive data types in Java with a comprehensive comparison table. Include size, range, default values, and real-world use cases for each.

Answer:

Java provides exactly 8 primitive data types divided into 4 categories:

1. Integer Types: byte (8-bit, -128 to 127 โ€” used for file I/O and network data), short (16-bit, -32768 to 32767 โ€” rarely used, sometimes for legacy systems), int (32-bit, ~ยฑ2.1 billion โ€” the default integer type for most calculations), long (64-bit, ~ยฑ9.2 quintillion โ€” for large IDs like Aadhaar numbers and timestamps).

2. Floating-Point Types: float (32-bit, ~7 decimal digits โ€” for graphics and approximate calculations, must use f suffix), double (64-bit, ~15 decimal digits โ€” default decimal type, used for financial calculations and scientific computing).

3. Character Type: char (16-bit Unicode, 0 to 65535 โ€” stores single characters including Unicode like 'โ‚น'. Uses single quotes).

4. Boolean Type: boolean (~1 bit โ€” only true or false, used for conditions and flags).

Key points: All sizes are fixed (platform-independent). Instance/static variables get defaults (0, 0.0, '\u0000', false). Local variables must be manually initialised. Literals: long needs L suffix, float needs f suffix.

LA-2: Explain Wrapper Classes in Java. Discuss autoboxing, unboxing, and important methods of Integer, Double, Character, and Boolean classes with code examples.

Answer:

Wrapper classes provide an object representation for each primitive type: intโ†’Integer, doubleโ†’Double, charโ†’Character, booleanโ†’Boolean, etc. They exist because Java Collections (ArrayList, HashMap) require objects, not primitives.

Autoboxing (Java 5+): Automatic primitive โ†’ Wrapper conversion.

Java
Integer x = 42;  // compiler converts to Integer.valueOf(42)
ArrayList<Double> prices = new ArrayList<>();
prices.add(99.99);  // double autoboxed to Double

Unboxing: Automatic Wrapper โ†’ primitive conversion.

Java
Integer obj = Integer.valueOf(100);
int val = obj;  // Integer unboxed to int

Key Methods: parseInt(String) โ€” String to int. valueOf(int) โ€” int to Integer. toString(int) โ€” int to String. toBinaryString(int) โ€” int to binary representation. Character.isDigit(char), Character.isLetter(char), Character.toUpperCase(char). Boolean.parseBoolean(String) โ€” only returns true for the exact string "true".

Important Caveat: Integer caching (-128 to 127) means == works for small values but fails for larger values. Always use .equals() for Wrapper comparisons.

LA-3: Explain the static keyword in Java with all 5 uses. Illustrate with a real-world class design example.

Answer:

The static keyword means "belongs to the class, not to any specific object." It has 5 uses:

1. Static Variable: Shared across all instances. Example: static int totalAccounts = 0; in a BankAccount class โ€” incremented in constructor, tracks total accounts created.

2. Static Method: Can be called without creating an object. Cannot access instance variables or use this. Example: static double calculateGST(double amount) โ€” utility method that doesn't need object state.

3. Static Block: Executes once when the class is first loaded (before any constructor). Used for complex static variable initialisation. Example: Loading database configuration from a file.

4. Static Nested Class: An inner class that doesn't hold a reference to the outer class instance. Used for helper/utility classes. Example: Map.Entry is a static nested class inside Map.

5. Static Import: import static java.lang.Math.*; lets you use sqrt(25) instead of Math.sqrt(25). Improves readability for frequently used utilities.

Java
public class BankAccount {
    static int totalAccounts = 0;           // 1. Static variable
    static { System.out.println("Bank system initialized"); }  // 3. Static block
    private String holder;
    private double balance;
    BankAccount(String name) { holder = name; totalAccounts++; }
    static int getTotalAccounts() { return totalAccounts; } // 2. Static method
}
Section I

Lab Programs โ€” Additional Practice

The primary lab for this unit is the Currency Converter covered in Section D (3-Tier Labs). Additional practice programs are included in the Problem Set (Section E). Focus on completing all three tiers of the currency converter lab before moving to the next unit.

Recommended practice order: Complete Tier 1 (guided) โ†’ Attempt all 8 programming questions from Section E โ†’ Complete Tier 2 (semi-guided) โ†’ Try the 3 industry questions โ†’ Complete Tier 3 (open challenge). This progression builds skill incrementally.
Section J

Industry Spotlight โ€” A Day in the Life

๐Ÿ‘ฉโ€๐Ÿ’ป Priya Nair, 27 โ€” Backend Java Developer at Razorpay, Bangalore

Background: B.Tech (IT) from NIT Calicut. Learned Java in 2nd year. Built a UPI payment simulator as a college project. Got placed at Razorpay through off-campus drive after showcasing her GitHub projects.

A Typical Day:

9:30 AM โ€” Morning standup with the Payments team. Discuss a bug where certain transaction amounts are showing โ‚น0.01 discrepancy due to floating-point precision errors.

10:00 AM โ€” Fix the bug: refactor payment amount storage from double (rupees) to long (paise). โ‚น999.99 โ†’ stored as 99999L paise. Uses Integer.parseInt() to validate merchant input.

11:30 AM โ€” Write unit tests. Tests use Boolean.parseBoolean() for config flags and Double.parseDouble() for expected amounts in test assertions.

1:00 PM โ€” Lunch at Razorpay's cafeteria in Koramangala. Discusses with teammate why they use static final constants for payment gateway codes.

2:00 PM โ€” Code review. Catches a junior developer using == to compare Integer objects instead of .equals(). Explains the Integer cache issue (-128 to 127).

4:00 PM โ€” Design a new PaymentConfig class. Uses private fields, public getters, static factory methods, and final constants. Pure data types and wrapper classes in action.

5:30 PM โ€” Attends internal tech talk on "Why Razorpay migrated from BigDecimal to long (paise) for payment processing."

DetailInfo
Tools Used DailyJava 17, Spring Boot, IntelliJ IDEA, Git, MySQL, Redis, JUnit
Entry Salary (2026)โ‚น4โ€“6 LPA + benefits
Mid-Level (3โ€“5 yrs)โ‚น12โ€“20 LPA
Senior (7+ yrs)โ‚น25โ€“45 LPA
Companies Hiring Java DevsRazorpay, Flipkart, PhonePe, Paytm, Zerodha, TCS, Infosys, Wipro, HCL, Amazon India, Google India
Java is the #1 most-demanded programming language on Naukri.com and LinkedIn India. Over 65% of Indian IT service companies (TCS, Infosys, Wipro, HCL) use Java as their primary backend language. Every concept in this chapter โ€” data types, casting, wrappers, access modifiers โ€” is used daily in production Java code.
Section K

Earn With It โ€” Currency Converter Widgets & Freelance Income

๐Ÿ’ฐ Your Earning Path After This Chapter

Portfolio Piece: "Multi-Currency Converter with Type-Safe Validation" โ€” a clean Java program demonstrating all data types, wrapper classes, and proper OOP design.

Beginner Gig Ideas:

โ€ข Currency converter widget for travel agency websites โ€” โ‚น3,000โ€“โ‚น8,000

โ€ข Unit conversion tool (kmโ†”miles, kgโ†”lbs, ยฐCโ†”ยฐF) for educational apps โ€” โ‚น2,000โ€“โ‚น5,000

โ€ข GST calculator with input validation for small businesses โ€” โ‚น2,000โ€“โ‚น6,000

โ€ข EMI calculator widget for loan comparison websites โ€” โ‚น5,000โ€“โ‚น12,000

PlatformBest ForTypical Rate
InternshalaJava internships & fresher projectsโ‚น3,000โ€“โ‚น10,000/project
FiverrQuick calculator/converter gigs$15โ€“$60/gig (โ‚น1,200โ€“โ‚น5,000)
UpworkJava development projects$20โ€“$50/hour
LinkedInDirect outreach to startupsโ‚น5,000โ€“โ‚น15,000/project
GitHub + PortfolioShowcase projects for placementsLeads to โ‚น4โ€“6 LPA jobs

โฑ๏ธ Time to First Earning: 2โ€“4 weeks (complete all 3 lab tiers, push to GitHub, create Fiverr/Internshala gig)

The EMI calculator is a goldmine gig. Every Indian loan comparison website (BankBazaar, PaisaBazaar, MyLoanCare) needs calculator widgets. Build one in Java, convert to a web widget using Spring Boot or JavaScript, and sell it. Single widget can earn โ‚น5,000โ€“โ‚น12,000.
Section L

Chapter Summary & Code Tweet

๐Ÿง  Key Takeaways from Unit 2

  • 8 primitive types: byte (1B), short (2B), int (4B), long (8B), float (4B), double (8B), char (2B), boolean (~1 bit)
  • Widening = automatic (small โ†’ big, no data loss). Narrowing = manual cast (big โ†’ small, risk of data loss)
  • 53 keywords โ€” reserved words like class, static, void. const & goto reserved but unused
  • Identifiers follow PascalCase (classes), camelCase (methods/variables), UPPER_SNAKE (constants)
  • 3 variable types: Local (method scope, no default), Instance (object scope, has default), Static (class scope, shared)
  • 4 access modifiers: public โ†’ protected โ†’ default โ†’ private (decreasing visibility)
  • static = belongs to class: 5 uses โ€” variable, method, block, nested class, import
  • Wrapper classes wrap primitives into objects: Integer, Double, Character, Boolean
  • Autoboxing = primitive โ†’ Wrapper. Unboxing = Wrapper โ†’ primitive
  • Key methods: parseInt(), valueOf(), toString(), parseDouble(), isDigit(), isLetter()

๐Ÿ“ฑ Code Tweet (< 280 chars)

int holds your salary, long holds your Aadhaar, double holds your wallet โ‚น, boolean holds your payment status, and Integer.parseInt() makes it all work. #Java #DataTypes #EduArtha ๐Ÿ‡ฎ๐Ÿ‡ณโ˜•

Section M

Earning Checkpoint โ€” What You've Mastered

Skill LearnedTool/MethodPortfolio OutputEarning-Ready?
8 Primitive Data TypesJava codeType demo programโœ… Yes โ€” fundamental interview skill
Type Casting & ConversionWidening/NarrowingConverter programsโœ… Yes โ€” used in every Java project
53 Keywords & IdentifiersJava referenceโ€”โœ… Yes โ€” MCQ/exam essential
Variable Types & ScopeLocal/Instance/StaticClass design programsโœ… Yes โ€” core interview topic
Access Modifierspublic/private/protectedOOP class designโœ… Yes โ€” architecture skill
Static Keyword (5 uses)Static var/method/blockUtility class programsโœ… Yes โ€” top interview question
Wrapper ClassesInteger, Double, etc.Converter with validationโœ… Yes โ€” used in every production app
Currency ConverterComplete Java appGitHub portfolio projectโœ… Yes โ€” โ‚น3Kโ€“โ‚น8K freelance gig
Minimum Viable Earning Setup after this chapter: A GitHub repository with a polished Currency Converter + an Internshala/Fiverr profile with "Java Developer โ€” Converter & Calculator Widgets" gig = you can earn โ‚น5,000โ€“โ‚น15,000/month from Java utility projects while still in college.

โœ… Unit 2 complete. MCQs: 30. Ready for Unit 3!

[QR: Link to EduArtha video tutorial โ€” Java Data Types & Wrapper Classes]