Java Basics
Your first programs, from zero — variables and types, operators, conditions, loops, arrays, methods and strings.
- Module 1 of 11
- Beginner
- 9 chapters
- 1 h 9 min
This is the ground floor for every later module and for solving DSA problems in Java. Variables, loops, methods and arrays are what every interview solution is built from.
What you will be able to do
- Write, compile and run a Java program
- Use variables, types, operators and conditions correctly
- Write loops and methods without off-by-one mistakes
- Work with arrays and read input the way DSA problems need
Chapters
1. Your First ProgramJava is a programming language released by Sun Microsystems in 1995 (now owned by Oracle). It's one of the most used languages7 min2. Variables and TypesA variable is a named box in memory that holds a value.7 min3. Operatorsint / int truncates toward zero. The average of scores (a + b) / 2 with ints loses the fraction. Write (a + b) / 2.0, or cast8 min4. Strings, Printing and Input ConversionString is Java's type for text. Unlike the 8 primitives, it's a class — an object type (fully explained in4 min5. Making DecisionsA road with a fork and a signpost: "If you're going to Mysore, turn left; otherwise, continue straight." A program checks a question3 min6. Loopswhile — repeat while a condition is true (you don't know in advance how many times).6 min7. MethodsA method is a named block of code that does one job. (Other languages call these functions.)6 min8. ArraysAn array is a fixed-length sequence of values of one type, stored side by side in memory.8 min9. The Whole Program, and Reading Input the DSA WayEverything from Chapters 1–8 in one program:5 min
Extras
The Whole StoryThe whole module retold as one story — no new facts, a fast revision of Java Basics.RevisionInterview QuestionsReal interview questions on Java Basics, answered the way you would say them out loud.Interview prepQuick ReferenceGlossary and cheat sheet for Java Basics — the page to reread before an interview.Reference