KTU OOP Java2024 Scheme • 60M ESE
MODULE 1/Section 1: Introduction to Java

Introduction to Java, Features (Buzzwords) & Naming Conventions

HIGH PRIORITY (Prep Guide)Official Syllabus~14 min study
Official KTU 2024 Syllabus Topics Covered Here
Introduction to JavaFeatures of JavaJava naming conventions
Java Version Note: Java was created by James Gosling's Green Team at Sun Microsystems (originally named Oak in 1991, first released as JDK 1.0 in January 1996, acquired by Oracle in 2010). Modern LTS releases include Java 8, 11, 17, and 21.

1. Topic Introduction

Before writing a single line of Java, you need to understand what Java actually is and why industries trust it for everything from Android apps and banking servers to big-data engines. Unlike older languages tied to a single operating system or CPU, Java was engineered as both a programming language and a software platform so that code written once can run safely anywhere.

2. Start From Zero: The Universal Power Adapter & Standardized Blueprint

Imagine writing a recipe book in a universal symbol language instead of local slang. Any chef in Tokyo, Kochi, or London who has a small 'translator booklet' for those symbols can cook the exact same dish without you rewriting the recipe for every kitchen. In computing, your Java program is compiled into universal symbols called Bytecode (.class), and the 'translator booklet' installed on Windows, Linux, or macOS is the Java Virtual Machine (JVM).

Key Takeaway: Java separates writing code from hardware details: you write .java, compile to .class bytecode once, and run it on any OS that has a JVM.

3. Essential Exam Definitions

Java
A high-level, class-based, object-oriented, strongly typed programming language and software runtime platform developed at Sun Microsystems (led by James Gosling).
Write Once, Run Anywhere (WORA)
Java's portability guarantee: source code compiled once into platform-independent bytecode (.class) executes unchanged on any operating system or processor equipped with a compatible JVM.
Java Naming Conventions
Standardized capitalization and identifier rules (PascalCase for classes/interfaces, camelCase for methods/variables, UPPER_SNAKE_CASE for constants, lowercase dot-separated names for packages) that keep code readable and compliant with KTU standards.

4. Detailed Technical Explanation & Syntax

Java as Both a Language and a Platform

Java is unique because it is both a programming language (syntax rules, OOP constructs, types) and a software-only runtime platform running on top of hardware-based OS platforms.

The Java platform provides two core runtime components: the Java Virtual Machine (JVM), which executes bytecode, and the Java Application Programming Interface (API), a rich set of prebuilt libraries packaged in java.lang, java.util, java.io, javax.swing, and java.sql.

Historically, Java has been distributed in major editions: Java SE (Standard Edition, core desktop/CLI apps — our syllabus focus), Java EE / Jakarta EE (Enterprise web servers), and Java ME (Micro Edition for embedded devices).

Key Features of Java (The Java Buzzwords)

In KTU exams, explaining Java's features accurately is a classic 3-mark or 6-mark question. Understand the technical reason behind every buzzword:

  • Platform Independent & Architecture Neutral: javac compiles source to neutral .class bytecode rather than OS-specific .exe binaries; primitive sizes (e.g., int is always 4 bytes) never vary across CPUs.
  • Object-Oriented: Models software around interacting objects using Encapsulation, Inheritance, Abstraction, and Polymorphism. Note: Java is NOT a 100% pure OOP language because it retains 8 primitive non-object types (int, char, etc.) for performance.
  • Simple: Familiar C/C++-like syntax, but removes error-prone complexity such as explicit pointer arithmetic, manual free() calls, operator overloading, and multiple class inheritance.
  • Secure: Runs inside the JVM sandbox, eliminates raw memory pointers, verifies bytecode integrity before execution (Bytecode Verifier), and enforces compile/runtime access rules.
  • Portable: Because bytecode has no implementation-dependent size assumptions, the exact .class file runs identically across Windows, Linux, and macOS.
  • Robust: Strong compile-time type checking, runtime boundary checks (catching null pointers and out-of-bounds array indexing), exception handling, and automatic Garbage Collection prevent memory leaks and crashes.
  • Multithreaded: Built-in thread support lets one program perform multiple tasks concurrently (e.g., UI painting while downloading data).
  • Compiled and Interpreted (High Performance): Combines ahead-of-time compilation to bytecode (javac) with JVM interpretation plus Just-In-Time (JIT) compilation of hot paths into native machine code.
  • Distributed & Dynamic: Networking APIs and RMI allow objects across networks to collaborate; classes are loaded and linked dynamically on demand at runtime.

Official Java Naming Conventions & Identifier Rules

Your syllabus explicitly notes: '[Use proper naming conventions]'. Distinguish between strict compiler rules (violation causes compile error) and standard naming conventions (expected in exam answers).

  • Compiler Rules for Identifiers: May contain letters, digits, underscore (_), and dollar ($); must NOT start with a digit; cannot contain spaces; cannot be a reserved keyword (class, int, public); strictly case-sensitive (total ≠ Total).
  • Classes & Interfaces -> PascalCase (UpperCamelCase): Nouns for classes (StudentRecord, BankAccount), adjectives/capabilities for interfaces (Serializable, Runnable, ActionListener).
  • Methods & Variables -> camelCase: Verbs for methods (calculateTotal(), getBalance()), meaningful nouns for variables (studentAge, rateOfInterest). Avoid single-letter cryptic names except loop counters (i, j).
  • Constants (static final) -> UPPER_SNAKE_CASE: All capitals with underscores (MAX_MARKS, PI, EXIT_ON_CLOSE).
  • Packages -> all lowercase: Reverse domain style (com.ktu.oop, java.util).

5. Working Principle: How Naming Conventions & Platform Neutrality Work Together

  1. Every public top-level class ClassName must reside in a file named identically ClassName.java (case-sensitive).
  2. Identifiers obey compiler lexical rules so javac can tokenize classes, fields, and methods unambiguously.
  3. Standard capitalization allows any Java developer (and university examiner) to instantly distinguish a class (String), a method (charAt()), a variable (userName), and a constant (MAX_VALUE).

6. Examination-Ready Diagrams

Diagram 2

Java Program Compilation and Execution

Source CodeProgram.javaJava Compilerjavac Program.javaBytecode (.class)Platform Independent (WORA)Windows JVMInterpreter/JIT -> x64 MachineLinux JVMInterpreter/JIT -> ELF MachinemacOS JVMInterpreter/JIT -> ARM64/x64Compile Time (Once)Runtime (Anywhere)

Two-stage hybrid compilation and interpretation flow demonstrating Write Once, Run Anywhere (WORA) across Windows, Linux, and macOS.

Key Components
  • Source Code (.java): Human-readable Java class file written by the programmer.
  • Java Compiler (javac): Checks syntax/types and translates .java into platform-independent bytecode.
  • Bytecode (.class): Intermediate binary instructions executed by any JVM.
  • Platform-Specific JVM: Windows JVM, Linux JVM, or macOS JVM interprets/JIT-compiles bytecode into native machine code.
Step-by-Step Flow
  1. Write source file e.g. HelloWorld.java.
  2. Run javac HelloWorld.java to compile source into HelloWorld.class (Bytecode).
  3. Run java HelloWorld to launch the OS-specific JVM.
  4. JVM loads bytecode, verifies it, and translates it via Interpreter + JIT into host CPU machine code.
How to Draw in KTU Exam
  • Use a clean left-to-right pipeline: .java -> [javac Compiler] -> .class (Bytecode).
  • Branch .class (Bytecode) into 3 boxes: JVM (Windows), JVM (Linux), JVM (macOS) -> Machine Code.
  • Label .class clearly as 'Platform Independent Bytecode (WORA)'.

7. Complete Java Code Examples & Tracing

Clean Java Program Demonstrating Naming ConventionsStudentGradeCard.java
Illustrates proper PascalCase class names, camelCase methods/variables, UPPER_SNAKE_CASE constants, and valid Java identifier rules.
1public class StudentGradeCard {
2 // Constant in UPPER_SNAKE_CASE
3 public static final int MAX_ESE_MARKS = 60;
4
5 // Instance variables in camelCase
6 private String studentName;
7 private int obtainedMarks;
8
9 public StudentGradeCard(String studentName, int obtainedMarks) {
10 this.studentName = studentName;
11 this.obtainedMarks = obtainedMarks;
12 }
13
14 // Method name starts with a lowercase verb in camelCase
15 public double calculatePercentage() {
16 return (obtainedMarks * 100.0) / MAX_ESE_MARKS;
17 }
18
19 public static void main(String[] args) {
20 StudentGradeCard card = new StudentGradeCard("Ananya", 54);
21 System.out.println("Student: " + card.studentName);
22 System.out.println("ESE Score: " + card.obtainedMarks + "/" + MAX_ESE_MARKS);
23 System.out.println("Percentage: " + card.calculatePercentage() + "%");
24 }
25}
Expected Output
Student: Ananya
ESE Score: 54/60
Percentage: 90.0%
Keywords:publicclassstaticfinalprivatereturnnew
Common Exam & Coding Mistakes
  • Naming the file studentgradecard.java when the public class is StudentGradeCard (causes compile error).
  • Starting a variable name with a digit like int 1stMark = 50; (syntax error).
  • Using 100 / MAX_ESE_MARKS with integers, which performs integer division and truncates decimals.

Advantages

  • Truly portable across OSs and CPU architectures via JVM bytecode.
  • Automatic garbage collection and strict type safety prevent common C/C++ memory crashes.
  • Rich standard API reduces boilerplate for networking, collections, GUI, and databases.

Limitations / Disadvantages

  • Slightly slower startup and higher memory footprint than native compiled C/C++ binaries due to JVM overhead.
  • Not pure object-oriented because primitive types exist outside the Object hierarchy.

Real-World Applications

  • Android mobile applications and enterprise banking systems requiring strict security.
  • Large-scale backend web microservices and big data platforms (Apache Hadoop, Elasticsearch, Kafka).
  • Cross-platform developer tools such as IntelliJ IDEA, Eclipse, and NetBeans.

Important KTU Exam Points

  • Always state BOTH: Java is a programming language AND a software platform (JVM + Java API).
  • Explain why Java is NOT purely object-oriented: presence of 8 primitive data types.
  • For WORA / Platform Independence questions, link javac -> .class bytecode -> OS-specific JVM.
  • Follow Java naming conventions strictly in all exam code answers (PascalCase classes, camelCase methods/variables, UPPER_SNAKE constants).

Memory Techniques & Revision

  • Buzzwords Mnemonic — 'SPDR-MP-OA': Simple, Secure, Portable, Distributed, Robust, Multithreaded, Platform-independent, Object-Oriented, Architecture-neutral.
  • Naming Rule: Class = Big-Big (PascalCase), Method/Var = small-Big (camelCase), Constant = ALL_CAPS.

Common Pitfalls to Avoid

  • Writing 'JVM is platform independent' — WRONG! Bytecode is platform independent; each OS requires its own platform-DEPENDENT JVM.
  • Claiming Java is 100% purely object-oriented without mentioning primitive types.

KTU-Style Questions & Exam-Ready Answers

Structured specifically for KTU Part A (3-mark) and Part B (6/9-mark) evaluation rubrics.

Introduction: Java achieves platform independence through a two-step compilation and execution model centered on bytecode.

  • Source code (.java) is compiled by javac into intermediate .class bytecode rather than native machine instructions.
  • Bytecode is architecture-neutral and identical regardless of which OS compiled it.
  • At runtime, a platform-specific JVM translates this bytecode into native CPU instructions, enabling Write Once, Run Anywhere (WORA).
Exam Diagram Note: Draw: .java -> javac -> .class (Bytecode) -> Windows JVM / Linux JVM / macOS JVM.

Quick Understanding Check

1. Which component of Java is actually platform-independent?

2. Why is Java often described as NOT 100% pure object-oriented?