A comprehensive guide to all Java 1.0 concepts with practical examples for interview preparation.
- Core Language Features
- Object-Oriented Programming
- AWT (Abstract Window Toolkit)
- Applets
- Basic I/O
- Common Interview Questions
Java 1.0 introduced the fundamental language constructs that form the basis of Java.
// Hello World
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}// Primitive data types
byte b = 127;
short s = 32767;
int i = 2147483647;
long l = 9223372036854775807L;
float f = 3.14f;
double d = 3.14159;
char c = 'A';
boolean bool = true;// If-else
if (condition) {
// code
} else {
// code
}
// Switch
switch (value) {
case 1:
// code
break;
default:
// code
}
// Loops
for (int i = 0; i < 10; i++) {
// code
}
while (condition) {
// code
}
do {
// code
} while (condition);- Platform Independence: Write once, run anywhere
- Object-Oriented: Classes, objects, inheritance, polymorphism
- Memory Management: Automatic garbage collection
- Type Safety: Strong typing system
- Exception Handling: Try-catch-finally blocks
See CoreLanguageFeatures.java for complete example.
Java 1.0 established the core OOP principles.
// Class definition
public class Person {
private String name;
private int age;
// Constructor
public Person(String name, int age) {
this.name = name;
this.age = age;
}
// Methods
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}// Base class
class Animal {
void makeSound() {
System.out.println("Animal makes sound");
}
}
// Derived class
class Dog extends Animal {
@Override
void makeSound() {
System.out.println("Dog barks");
}
}Animal animal = new Dog();
animal.makeSound(); // Polymorphic call- Classes: Blueprint for objects
- Objects: Instances of classes
- Inheritance: Extending classes
- Polymorphism: Method overriding
- Encapsulation: Data hiding with private fields
See OOPConcepts.java for complete example.
AWT provides the foundation for GUI development in Java.
import java.awt.*;
public class BasicWindow extends Frame {
public BasicWindow() {
setTitle("My Window");
setSize(400, 300);
setVisible(true);
}
public static void main(String[] args) {
new BasicWindow();
}
}import java.awt.*;
public class ComponentExample extends Frame {
public ComponentExample() {
setLayout(new FlowLayout());
// Button
Button btn = new Button("Click Me");
add(btn);
// Label
Label label = new Label("Hello AWT");
add(label);
// TextField
TextField textField = new TextField(20);
add(textField);
setSize(300, 200);
setVisible(true);
}
}- Components: Buttons, labels, text fields, etc.
- Layout Managers: FlowLayout, BorderLayout, GridLayout
- Event Handling: ActionListener, WindowListener
- Graphics: Drawing capabilities
See AWTExample.java for complete example.
Applets allow Java programs to run in web browsers.
import java.applet.Applet;
import java.awt.Graphics;
public class HelloApplet extends Applet {
public void paint(Graphics g) {
g.drawString("Hello, World!", 20, 20);
}
}import java.applet.Applet;
import java.awt.Graphics;
public class LifecycleApplet extends Applet {
public void init() {
// Initialization
}
public void start() {
// Applet starts
}
public void paint(Graphics g) {
// Drawing
}
public void stop() {
// Applet stops
}
public void destroy() {
// Cleanup
}
}- Browser Integration: Run in web browsers
- Lifecycle Methods: init(), start(), stop(), destroy()
- Graphics: Drawing on applet surface
- Security: Sandboxed execution
Note: Applets are deprecated in modern Java. This is for historical reference.
See AppletExample.java for complete example.
Java 1.0 provides basic input/output capabilities.
import java.io.*;
public class FileIOExample {
public static void main(String[] args) {
// Writing to file
try {
FileWriter writer = new FileWriter("output.txt");
writer.write("Hello, Java 1.0!");
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
// Reading from file
try {
FileReader reader = new FileReader("input.txt");
BufferedReader br = new BufferedReader(reader);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}// Console output
System.out.println("Hello, World!");
System.out.print("No newline");
// Console input (using BufferedReader)
BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in)
);
String input = reader.readLine();- File I/O: FileReader, FileWriter, BufferedReader
- Streams: InputStream, OutputStream
- Exception Handling: IOException handling
- Console I/O: System.in, System.out, System.err
See FileIOExample.java for complete example.
A: Key features:
- Platform independence (Write Once, Run Anywhere)
- Object-oriented programming
- Automatic garbage collection
- Strong type system
- Exception handling
- AWT for GUI development
- Applets for web integration
A:
- Platform Independence: Java bytecode runs on any platform with JVM
- Automatic Memory Management: Garbage collection
- Strong Typing: Compile-time type checking
- Object-Oriented: Everything is an object (except primitives)
A: An applet is a Java program that runs in a web browser:
- Embedded in HTML pages
- Has lifecycle methods (init, start, stop, destroy)
- Runs in a sandboxed environment
- Note: Deprecated in modern Java
A: Abstract Window Toolkit:
- Provides GUI components
- Platform-dependent native components
- Layout managers for component arrangement
- Event handling mechanism
A:
- Java source code is compiled to bytecode
- Bytecode runs on Java Virtual Machine (JVM)
- JVM is platform-specific but bytecode is platform-independent
- "Write Once, Run Anywhere" principle
Last Updated: 2025
Version: 1.0
This guide covers the foundational features of Java 1.0, released on January 23, 1996.