JAVA PROGRAMMING
Conceptual Notes for Internship Technical Exam
Covers: Java Setup · Basics · Data Types · Type Casting · Strings · Arrays · Operators · Constants · Control Flow · Functions ·
OOP Fundamentals
Table of Contents
TOC \h \o "1-2"
1. Introduction & Environment Setup
1.1 What is Java?
Java is a high-level, object-oriented, platform-independent programming language. Code written in Java is
compiled into
bytecode (not directly into machine code), which runs on the JVM (Java Virtual Machine). This is why Java
follows the principle:
Key Principle
1.2 Setting Up Java
• JDK (Java Development Kit) — must be downloaded and installed first. It contains the compiler (javac),
the JVM, and core libraries needed to write and run Java programs.
• IDE (Editor) — IntelliJ IDEA (Community Edition, free) is commonly used. Alternatives include Eclipse and VS
Code with Java extensions.
• When creating a new project, the SDK version selected should match the installed JDK version.
1.3 Projects & Packages
When a new Java project is created, source files are organized inside **packages**. A package is simply a
folder/namespace used to group related classes together — similar to how a library groups books of the same
subject on the same shelf.
Concept Explanation
Naming Convention
2. Your First Java Program
2.1 Structure of a Java Program
public class Main {
public static void main(String[] args) {
[Link]("Hello World");
}
}
• Every Java application must have a class, and execution starts from the main method.
• public static void main(String[] args) is the fixed entry-point signature — the JVM looks for
this exact method to start running the program.
• Every statement in Java ends with a semicolon `;`
2.2 print vs println vs printf
Method Behaviour
IDE Shortcut
3. Variables & Data Types
3.1 What is a Variable?
A variable is a named location in memory used to store a value. Java is a **statically typed** language, meaning
the data type of a variable must be declared before use, and that type cannot change afterwards.
String name = "Aman"; // storing text
int age = 20; // storing a whole number
3.2 Primitive Data Types
Java has 8 primitive data types, each reserving a fixed amount of memory:
Type Memory Size Range / Use Example
Note
Type Memory Size Range / Use Example
3.3 Default / Uninitialized Values
If a variable is declared but not assigned a value, Java auto-initializes it to a default (this mainly applies to
instance/class-level variables, not local variables inside methods, which must be initialized before use):
Type Default Value
4. Type Casting
Type casting means converting a variable from one data type to another.
4.1 Implicit Casting (Widening)
Happens automatically when converting a **smaller** data type into a **larger** one — no data is lost, so Java
allows it silently.
int a = 10;
double b = a; // int -> double, done automatically
4.2 Explicit Casting (Narrowing)
Required when converting a **larger** data type into a **smaller** one. This can cause data/precision loss, so
the programmer must manually specify the cast.
double d = 9.78;
int x = (int) d; // explicit cast, x becomes 9 (decimal part lost)
Exam Tip
5. Constants — the `final` Keyword
A variable declared with `final` cannot be reassigned once a value is given to it. Attempting to change it causes a
compile-time error.
final int MAX_SCORE = 100;
MAX_SCORE = 200; // ERROR: cannot assign a value to final variable
• Convention: constants (final variables) are named in UPPERCASE with underscores, e.g. MAX_SCORE,
PI_VALUE.
6. Strings
A `String` in Java is an object used to store a sequence of characters (text).
String greeting = "Hello";
String name = new String("Aman"); // rarely needed; direct assignment is
preferred
6.1 Important String Methods
Method Purpose Example
6.2 Strings are Immutable
Important Concept
7. Arrays
An array is a data structure that stores multiple values of the **same type** under a single variable name,
avoiding the need to create many separate variables.
int[] marks = {90, 85, 78};
[Link](marks[0]); // 90 (first element)
[Link](marks[1]); // 85 (second element)
• Declared using square brackets `[]` after the data type: int[] arr, String[] names, char[]
letters.
• Indexing starts at 0 — the first element is arr[0], not arr[1].
• Elements are accessed/modified using the index inside square brackets: marks[2] = 100;
7.1 Useful Array Properties/Functions
Property/Function Purpose Example
Exam Tip
8. Operators
8.1 Arithmetic Operators
Operator Meaning Example (a=11, b=2)
Exam Tip
8.2 Assignment Operators
Operator Equivalent to
8.3 Comparison & Logical Operators
Operator Meaning
Operator Meaning
8.4 Math Class Helper Functions
Function Purpose Example
9. Control Flow Statements
These decide the order in which statements execute. This topic is essential for internship exams and is a natural
extension of the comparison/logical operators covered above.
9.1 Conditional Statements
if (marks >= 90) {
[Link]("Grade A");
} else if (marks >= 75) {
[Link]("Grade B");
} else {
[Link]("Grade C");
}
• `switch` statement — an alternative to long if-else chains when comparing one variable against multiple
fixed values:
switch (day) {
case 1:
[Link]("Monday");
break;
default:
[Link]("Invalid day");
}
Exam Tip
9.2 Loops
Loop Use Case
for (int i = 0; i < 5; i++) {
[Link](i);
}
• `break` — exits the loop immediately.
• `continue` — skips the current iteration and moves to the next one.
10. Methods (Functions)
A method is a reusable block of code that performs a specific task. Methods help avoid repeating code and make
programs modular.
public static int add(int a, int b) {
return a + b;
}
// calling the method:
int result = add(5, 3); // result = 8
Part Meaning
Note
11. Object-Oriented Programming (OOP) Basics
Java is an object-oriented language. Internship exams frequently test the four core OOP pillars and basic
class/object syntax, so this section extends beyond the video's content.
11.1 Class & Object
Term Meaning
class Student {
String name;
int age;
}
Student s1 = new Student(); // creating an object
[Link] = "Aman";
11.2 Constructors
A constructor is a special method used to initialize an object when it's created. It has the same name as the class
and no return type.
class Student {
String name;
Student(String n) { // constructor
name = n;
}
}
Student s1 = new Student("Aman");
11.3 The Four Pillars of OOP
Pillar Meaning
11.4 Access Modifiers
Modifier Visibility
Modifier Visibility
12. Quick Revision Summary
• Java code compiles to bytecode, run by the JVM → platform independent.
• Program entry point: public static void main(String[] args)
• print → no newline · println → newline · printf → formatted output
• 8 primitive types: byte, short, int, long, float, double, char, boolean
• Implicit casting = small → large (automatic); Explicit casting = large → small (manual, may lose data)
• final = constant, cannot be reassigned; written in UPPERCASE by convention
• Strings are immutable — methods like .replace() return a new string
• Arrays use .length (property); Strings use .length() (method) — do not confuse the two
• Array indexing starts at 0
• == compares values/references, .equals() compares String content
• Control flow: if-else, switch, for, while, do-while
• OOP pillars: Encapsulation, Inheritance, Polymorphism, Abstraction