click below
click below
Normal Size Small Size show me how
Java Basics
Basic Java interview questions
Question | Answer |
---|---|
What is Java? | Java is one of the most popular high level programming languages. For example, its used to create mobile application like Netflix, Twitter, Spotify, and many more. Also, used in the server applications. |
What is the JDK?(Java Development Kit | JDK contains everything that JRE has JDK used to develop Java applications.JDK contains compiler (javac.exe), Java application launcher (java.exe), Applet viewer javac - Java compiler translates java source code into byte code. |
What is the JRE?(Java Runtime Environment) | JRE is a software package which bundles the libraries (jars) and the JVM, and other components to run applications written in the Java. To execute any Java application, you need JRE installed in the machine. |
What is JVM? | JVM - Java Virtual Machine JVM interprets the byte code into the machine code and execute it. |
What is the difference between JDK, JVM, & JRE? | JDK is a software development kit whereas JRE is a software bundle that allows Java program to run, whereas JVM is an environment for executing bytecode. JRE = JVM + libraries to run Java application JDK = JRE + tools to develop Java application |
What are the types of access modifiers? Which one is more protective? | allow us to set the scope or accessibility, or visibility of a data member be it a field, constructor, class, or method. Public Protected Private Default Private is more protective can access them only within the class in which they are declared. |
Tell us about non-access modifiers | Non-access modifiers define the behavior of the entities to the JVM, used with classes, variables, methods, constructors, etc. Some of the non-access modifiers are static final abstract synchronized |
Brief us on Java Memory (or) How many memories are there in Java and what are they used for? | There are two kinds of memory used in Java: Stack memory stores primitive types and the addresses of objects. Heap memory stores the value of the object. |
What is garbage collection? | Garbage collection is the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects. |
Where are objects stored? (or) When an object is instantiated where is it stored? | Whenever an object is created, it's always stored in the Heap memory and stack memory contains the reference of it. |
What is local scope? | When we create a variable within a method, it cannot be accessed outside that method. The scope of that variable is a local scope. |
What is instance scope? | Instance Scope Its the scope of the instance variables Instance variables are declared inside a class, but outside a method. Instance variables can been seen by all methods in the class. |
What are the different scopes in java? | Variables can be defined as having one of three types of scope: Class level scope or Instance scope (instance variables): Any variable declared within a class is accessible by all methods in that class. Method level scope or Local scope (local variables |