Programming interview questions can cover a whole range of topics, from concepts in programming to terminology, logical thinking and knowledge on programming languages. In this blog, I will cover five basic interview questions and answers specific to Java.
- What is an access modifier and how is it used? Can you give an example of one?
An access modifier can restrict the access of a class, constructor, method, or data member. This is important to use because there will be instances where you only want to access a data member through one specific class, or instead you want that data member to be accessible anywhere in the program.
The access modifier is used by using any of the four key words: public, private, protected, or default. Placing that keyword in front of the data type will verify the access modifier you used (i.e. public void main, private String stringName)
2. What is the keyword used to get a package into your program?
The keyword you would need to use is import, and you place this keyword at the very top of your program, along with what library your using and the specific package/class you want to import. (As shown below)
import java.util.Scanner; // import the Scanner class from utility package
3. What is the difference between a double and a float?
Floats and doubles both deal with decimal point values. However, the main difference between them is doubles are larger in size (64 bits) while float values are smaller (32 bits). What this means, however, is that doubles use more decimal points that floats and are more precise (floats use single precision while doubles have double precision). One other key difference is in java, any math formulas will output values automatically has a double.

4. What is the difference between int and Integer?
In Java, int is a primitive data type integer (a whole number). Integer is a class type from Java (that is part of the java.lang package) and Integer storereferences to Integer objects (MIN_VALUE, MAX_VALUE –> to get the minimum and maximum integer values)
5. What are the four pillars of Object Oriented Programming?
APIE (Abstraction, Polymorphism, Inheritance, Extraction)
