What You Should Know
Most of you took Intro Java last semester, but it is easy to lose the details over a break. Some of you took the prerequisite a while ago. This page is the starting list of what I expect you to walk in already knowing.
If you would like to reference the Intro to Java Programming website use the following link and credentials:
- Intro to Java Programming
- username:
java111 - password:
java rocks!
How to use this page
Work through each topic below and quietly answer the questions to yourself. If you can explain the concept and write the code without looking it up, you are set. If a topic feels shaky, make a note of it and use the review plan at the bottom of the page to fill the gap. You do not need every item memorized on day one. You do need a plan for the ones that are not solid yet.
The topics are grouped into six areas: classes and program structure, variables and constants, data and memory, methods, documentation and formatting, and building and running your code.
Classes and Program Structure
The shape of a Java program: what a class is, where the code lives, how it is organized into packages, and how interfaces fit in.
Java Classes
public class Hello {
// What's first in a class?
}
Java Source Code
- How do file names relate to class names?
- Where's my code?
Java Packaging
package java112.analyzers;
- What is a package?
- How does a package relate to the file system?
Interfaces
public interface Analyzer {
// What goes here?
}
Variables and Constants
Where your data is stored, and the difference between data that belongs to an object, data that belongs to the class, and values that never change.
Instance Variables
- What word will be at the start of every instance variable definition? Hint: not
public.
Class Variables (Static Variables)
- How do you make a class variable?
- Where do they go in your code?
- What does that word, "static", really mean?
Constants
- Constants are declared with
static finaland named inALL_CAPS_WITH_UNDERSCORES. - What would a constant for the maximum number of login attempts look like?
private static final int MAX_LOGIN_ATTEMPTS = 3;
Data Types, Objects, and Memory
How Java stores values, the critical difference between a primitive value and an object reference, and how objects come into existence.
Java Primitive Data Types
- int
- long
- float
- double
- boolean
Java Object References
This one is really important.
// Can you tell me what every word and operator means here?
String firstName = "Fred";
Dog myDog = new Dog();
Instantiation of Objects
- Creating a new object from a class is called instantiation. It uses the
newkeyword. - What does
newactually do? (Hint: think about memory.)
Dog myDog = new Dog(); // instantiates a Dog object and assigns it to myDog
Java Arrays
// Arrays of String
// Declare an array of String reference variable
String[] stringArray;
// Create an array that can hold 3 Strings
// and assign the reference to the reference variable
stringArray = new String[3];
// Assign the first element of the array to a String
stringArray[0] = "Bill";
// Assign the second element of the array to a String
stringArray[1] = "Sue";
// Assign the third element of the array to a String
stringArray[2] = "Kim";
// Loop through the array and output each String to the terminal
for (int index = 0; index < stringArray.length; index++) {
System.out.println(stringArray[index]);
}
- What does
stringArray.lengthmean? - What does
new String[3]mean?
Methods
The Special main() Method
// Can you type this from memory?
public static void main(String[] arguments) {
}
- What is so special about this method?
- What do we always do inside a
mainmethod?
Documentation and Formatting
Code is read far more often than it is written. These two habits are what make your code readable to teammates, to your instructor, and to future you.
Java Code Formatting
- What is your code supposed to look like?
- Is it really that important? Yes.
- Consistent formatting makes your code readable by teammates and instructors. We follow the course coding standards, so review them before writing a single line.
Javadoc Comments
- Javadoc is how you document your code so others (and future you) can understand it.
- Every class and every public method needs a Javadoc comment.
/**
* Reads a file and returns the number of lines it contains.
*
* @param filePath the path to the file to read
* @return the number of lines in the file
*/
public int countLines(String filePath) { ... }
Compiling, Running, and Debugging
How your source becomes a running program in this course, and how to read the errors when it does not.
Compiling Java Classes
- All that typing on the command line, there must be a better way. There is.
- We use ant to compile. See the Compiling and Running Applications page.
Running Java Applications
- We run applications using shell scripts configured for this course.
- See the Compiling and Running Applications page for the specific scripts and commands.
Reading Java Stack Traces
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
Caused by: java.lang.ClassNotFoundException: Hello
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
- Where do you look first in a stack trace?
- What is this particular error telling you?
Not sure about some of these?
That is completely normal, and it does not mean you are behind or that you do not belong here.
Students come into this course from all different starting points. Some of you finished Intro Java last semester. Others took it a year or two ago. Some of you passed the course but still feel shaky on a few topics. All of that is okay. What matters is that you are here now and willing to do the work.
You do not need to have every concept on this page perfectly memorized before Week 1 ends. What you do need is a plan for filling in any gaps as we move forward.
Here is what to do
Review your previous materials. Pull out your notes, textbook, or assignments from Intro Java. Looking at code you wrote before is one of the fastest ways to bring things back.
Use the official Java documentation. The Java API documentation is a professional resource you will use throughout your career. It is also a great place to look up how specific classes and methods work. Bookmark it now.
Ask for help early. The best time to ask a question is before you are stuck and frustrated. If something on this page is not clicking, reach out.
- Post in the course Ask Anything! channel on Teams. Your classmates and instructor check it regularly.
- Get in touch with me before Week 2 begins. This is the ideal time to talk through anything you are unsure about, before the first assignments are due.
Know that review is part of learning. Every experienced developer looks things up and revisits fundamentals. Reviewing a concept you learned before is not starting over. It is building a stronger foundation.
You are in this course because you earned your way here. If you have questions or feel uncertain, that is a signal to reach out, not a reason to stay quiet.
Using AI to Review These Concepts
AI as a study partner
You can ask an AI assistant to quiz you on any of the topics on this page. For example:
"Quiz me on Java instance variables vs. class variables. Ask me one question at a time and tell me if I'm right."
This is a legitimate and effective study technique. However, you should be able to write and explain this code without AI assistance. Labs and assessments will test that directly.
If you ask AI to explain a concept and its answer doesn't match what we cover in class, bring it up. AI explanations are sometimes correct but use different terminology or conventions than this course requires.