DEV Community

Cover image for A Beginner’s Approach to Java
Isah Jacob
Isah Jacob

Posted on • Originally published at Medium

A Beginner’s Approach to Java

When it comes to Java, people have different ideas and opinions about the language itself. I believe this is based on individual experience. In this article I will be introducing you to the world of Java and explaining a few questions that newbies who are learning Java ask.

Welcome to the World of Java.

If you have never written a line of code in your life and you are interested in learning Java, please take a cup of water before you read the next line. Java will be hard for you. It will be confusing, but rest assured that you will be fine at the end. But if you have done some coding before, you will be fine.

The first thing in every line of code is in your source code. This is where you write your code using test editors, and it is advisable to first use Notepad to get familiar with errors in your code when writing in Java before moving on to an IDE like IntelliJ.

The second thing is the compiler. The compiler runs through your source code and checks that there are no errors, and will not compile if there is an error. When a compiler creates a new document, this document is in bytecode. This bytecode can only be interpreted on any device that can run Java.

When the compiler has compiled your source code and sent the output to your devices, this process is taken care of by the Java Virtual Machine (JVM) that reads and runs the bytecode. Your computer as a device has a Java machine that reads and runs the byte code.

In Java, every line of code goes into the class and will have to be saved with the .java extension. Say you have a class called HelloWorld. It has to be saved as This is if you are coding with Notepad as a starter.

Let’s take a look at some common queries from newcomers.

What is a Java program, exactly?

A Java application contains many classes, but one of them must contain a main method. This is the primary method for launching the program.

`//Java class
public class HelloWorld {
public static void main (String[] args) {
//Java main method
person joy = new person();
Enter fullscreen mode Exit fullscreen mode

What is a Class?

The java class is the blueprint for every object and methods you create and everything in java is Object hence it is called an Object Oriented Programing language (OOP).

What is method in java?

A methods is a procedure for how a method should performed. E.g.

person grace = new person.
Enter fullscreen mode Exit fullscreen mode

What exactly is a Class?

The java class serves as the blueprint for all objects and methods you create, and because everything in java is an object, it is known as an Object Oriented Programming language (OOP).

What exactly is a method in Java?

A method is a procedure that describes how a method should be carried out. Person grace, from the example above, denotes a new person (we have created a new object). is a method ()

What exactly is a variable in Java?

Variables are containers that hold values. We have primitive and reference variables, variables as a return type, variables as an argument, and so on.

int age; where age = 27, 
Sting name; name = grace;
Enter fullscreen mode Exit fullscreen mode

What exactly are instance variables?

An instance variable is information that an object has about itself. We have a grace object made from a person, so what does grace know about herself? Her name, age, and home address. As a result, this becomes grace instance variable.

What’s the distinction between a class and an object?

A class is not an object, but an object can be constructed from a class.

Top comments (0)