0% found this document useful (0 votes)
2 views2 pages

Core Java Exam Cheat Sheet

This cheat sheet provides essential definitions and program templates for core Java concepts, including static, this, super, interfaces, and polymorphism. It includes example programs for file reversal, ArrayList reversal, method overloading for area calculations, and a simple AWT form with event handling. Additionally, it highlights key theoretical points such as Java's platform independence and exception handling.

Uploaded by

avdhutgatkal3
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Core Java Exam Cheat Sheet

This cheat sheet provides essential definitions and program templates for core Java concepts, including static, this, super, interfaces, and polymorphism. It includes example programs for file reversal, ArrayList reversal, method overloading for area calculations, and a simple AWT form with event handling. Additionally, it highlights key theoretical points such as Java's platform independence and exception handling.

Uploaded by

avdhutgatkal3
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CORE JAVA – EXAM CHEAT SHEET (One Page)

1) MUST-KNOW DEFINITIONS (2–3 lines each)

static: Belongs to class, not object.


this: Refers to current object.
super: Calls parent class constructor/method.
finalize(): Called before object destruction.
Interface: 100% abstract (till Java 7).
Abstract class: Contains abstract + concrete methods.
Polymorphism: Different forms (overloading/overriding).
Package: Groups related classes.
Stream: Flow of data in Java I/O.
Layout Manager: Controls AWT/Swing component layout.
2) PROGRAM TEMPLATES (Use directly in exam)
A) FILE REVERSE PROGRAM
import [Link].*;
class ReverseFile {
public static void main(String args[]) throws Exception {
BufferedReader br = new BufferedReader(new FileReader("[Link]"));
String line;
while((line = [Link]()) != null) {
StringBuilder sb = new StringBuilder(line);
[Link]([Link]());
}
[Link]();
}
}

B) ARRAYLIST REVERSE PROGRAM


import [Link].*;
class ALReverse {
public static void main(String args[]) {
ArrayList<Integer> a = new ArrayList<>();
Scanner sc = new Scanner([Link]);
int n = [Link]();
for(int i=0;i<n;i++) [Link]([Link]());
[Link](a);
[Link](a);
}
}

C) METHOD OVERLOADING – AREA


class Area {
double area(double r){ return 3.14*r*r; }
double area(double b, double h){ return 0.5*b*h; }
double area(int l, int b){ return l*b; }
}

D) SIMPLE AWT FORM + EVENT


import [Link].*;
import [Link].*;
class MyForm extends Frame implements ActionListener {
TextField t1 = new TextField(10);
Button b = new Button("OK");
MyForm(){
setLayout(new FlowLayout());
add(t1); add(b);
[Link](this);
setSize(300,200); setVisible(true);
}
public void actionPerformed(ActionEvent e){
[Link]("Entered: " + [Link]());
}
public static void main(String a[]){ new MyForm(); }
}

3) LAST-MINUTE THEORY POINTS

Java is platform-independent due to JVM + bytecode.


Overloading: Same method name, different parameters.
Overriding: Same method signature in subclass.
try–catch: Handles runtime exceptions.
Reader/Writer: Character streams.
ArrayList: Resizable array.

You might also like