Quick answer: For placement revision, learn these Core Java facts: the eight primitive types and their sizes, == versus equals, String versus StringBuilder, the four OOP pillars, overloading versus overriding, List, Set and Map, checked versus unchecked exceptions, and basic streams. This cheat sheet puts them in short tables with real outputs so you can test yourself.
This core Java cheat sheet is for the week before a placement test. Cover the right column of a table, say the answer, then check.
These core Java notes assume you have met the topics before. If not, start with the core Java tutorial. Code was run on Java 17.
Data types and operators
| Type | Size | Default |
|---|---|---|
byte |
1 byte | 0 |
short |
2 bytes | 0 |
int |
4 bytes | 0 |
long |
8 bytes | 0L |
float |
4 bytes | 0.0f |
double |
8 bytes | 0.0 |
char |
2 bytes | '\u0000' |
boolean |
not fixed | false |
Defaults apply to fields only. A local variable must be assigned before use.
| Rule | Remember |
|---|---|
int / int |
Drops the decimal: 7 / 2 is 3 |
% |
Remainder: 7 % 2 is 1 |
i++ vs ++i |
Use then add, or add then use |
&&, || |
Short-circuit: the right side may not run |
| Widening | int to long or double is automatic |
| Narrowing | double to int needs a cast and drops the decimal |
Strings
| Topic | Remember |
|---|---|
| Immutable | Methods return a new string |
== |
Same object? |
equals() |
Same text? |
| String pool | Literals with the same text share one object |
StringBuilder |
Changeable, fast, use in loops |
StringBuffer |
Like StringBuilder, but synchronized |
Common methods: length(), charAt(i), substring(a, b) (b is excluded), indexOf(), contains(), split(), trim(), toUpperCase(), replace(), String.join().
OOP in one table
| Pillar | Meaning | Java tool |
|---|---|---|
| Encapsulation | Hide data, expose methods | private fields with getters |
| Inheritance | Reuse a parent class | extends |
| Polymorphism | One call, many forms | Overloading and overriding |
| Abstraction | Show what, hide how | abstract class, interface |
| Overloading | Overriding | |
|---|---|---|
| Where | Same class | Parent and child |
| Parameters | Must differ | Must match |
| Decided at | Compile time | Run time |
| Return type | Can differ | Same or a subtype |
| Keyword | On a variable | On a method | On a class |
|---|---|---|---|
final |
Cannot reassign | Cannot override | Cannot extend |
static |
One copy per class | Call without an object | Only for nested classes |
| Abstract class | Interface | |
|---|---|---|
| Multiple | A class extends one | A class implements many |
| Fields | Any | Constants only |
| Constructor | Yes | No |
| Methods | Abstract and concrete | Abstract, default, static, private |
Access: private (class only), no modifier (same package), protected (package plus subclasses), public (everyone).
Collections
| Type | Order | Duplicates | Null | Typical use |
|---|---|---|---|---|
ArrayList |
Insertion | Yes | Yes | Most lists |
HashSet |
None | No | One | Unique items, fast lookup |
TreeSet |
Sorted | No | No | Sorted unique items |
HashMap |
None | Keys unique | One null key | Key to value lookup |
LinkedHashMap |
Insertion | Keys unique | One null key | Map in insertion order |
TreeMap |
Sorted keys | Keys unique | No null key | Sorted map |
Remember: Comparable gives one natural order inside the class (compareTo). Comparator gives extra orders from outside (Comparator.comparing(...)). For more depth, see the Java collections interview questions.
Exceptions
| Checked | Unchecked | |
|---|---|---|
| Parent | Exception |
RuntimeException |
| Compiler forces handling? | Yes | No |
| Examples | IOException, SQLException |
NullPointerException, ArithmeticException |
finallyruns whether or not an exception is thrown.throwthrows one exception.throwsin a method signature warns callers.- try-with-resources closes files and connections for you.
Lambdas and streams
List<Integer> marks = List.of(45, 82, 67, 91, 38);
List<Integer> passed = marks.stream()
.filter(m -> m >= 40)
.sorted()
.toList(); // [45, 67, 82, 91]
int total = marks.stream().mapToInt(Integer::intValue).sum(); // 323
| Term | Remember |
|---|---|
| Intermediate | filter, map, sorted, distinct: lazy, return a stream |
| Terminal | forEach, collect, count, sum, toList: run the pipeline |
| Functional interface | One abstract method, such as Runnable, Comparator |
Core Java quick revision: output traps
Predict each line before you read the output.
public class Traps {
public static void main(String[] args) {
System.out.println(1 + 2 + "3");
System.out.println("1" + 2 + 3);
System.out.println(10 / 4);
System.out.println(10 / 4.0);
System.out.println('A' + 1);
System.out.println((char) ('A' + 1));
Integer a = 128, b = 128;
System.out.println(a == b);
String s = "hi";
String t = "hi";
System.out.println(s == t);
int i = 5;
System.out.println(i++ + ++i);
System.out.println(Math.round(-2.5));
}
}
33
123
2
2.5
66
B
false
true
12
-2
Why: + works left to right, so numbers add until a string appears. 'A' is 65. Integers above 127 are not cached. Both "hi" literals share one pooled object. i++ gives 5, then ++i gives 7. Math.round rounds half up, so -2.5 becomes -2.
How to use this core Java cheat sheet
Revise one section a day: types and strings, then OOP, collections, exceptions and streams. On the last day, do the output traps and a timed test from our core Java practice problems.
If you search for a core Java PDF, print this page to PDF from your browser. Then check yourself with the core Java interview questions. To see where Core Java fits next to SQL, Spring Boot and React, read the Java full stack course guide.
Frequently asked questions
Is there a PDF of this Core Java cheat sheet?
There is no separate PDF to download. Open this page in your browser, choose Print and then Save as PDF to keep your own copy. You can also bookmark it on your phone for revision before a test.
Which Core Java topics should I revise first for placements?
Start with OOP, String handling and collections, because they come up in almost every fresher interview. Then revise exceptions, static and final, and simple streams.
Can I learn Core Java from a cheat sheet alone?
No. A cheat sheet helps you revise what you have already practised. To learn a topic for the first time, write and run small programs, then use this page to check that you still remember it.
How long does it take to revise Core Java before a test?
If you have studied it before, three to five focused days is usually enough to revise these tables and solve a few problems on each topic. If many topics feel new, give yourself a few weeks of practice.
Which Java version should I revise for interviews?
Revise Java 8 features such as lambdas and streams, since they are asked often, and practise on Java 17 or newer. Records and switch expressions from newer versions are a bonus.
Want to revise with a trainer instead of alone? Book a free demo class in our Madhapur, Hyderabad classroom or live online, or see the Java Full Stack with AI course.
