SlideShare a Scribd company logo
What is Java?
Java is a platform-independent, high-level, object-oriented, multithreaded, portable programming
language. It was originally designed by James Gosling of Sun Microsystems in June 1991. Released
in 1995 as a core component of Sun Microsystems. Sun Microsystems was then acquired by
Oracle, and Java was developed by Oracle. Currently Java is one of the most popular programming
languages ​
​
in the world. It is also considered a platform independent because it has its own JRE and
API.
What are the main features of Java?
The main Java features/properties are:
• Object Oriented - Java is an object-oriented programming language. This because Java programs
use classes and objects.
• Distributed - Information is distributed among different computers on the network.
• Rugged - Rugged means strong. Java programs are robust and do not crash as easily as C or
C++ programs. There are two reasons. First, Java has excellent built-in exception handling
capabilities, and second, memory management capabilities. Most 'C' and 'C++' programs crash
prematurely because they don't allocate enough memory. Java does not have this problem because
it does not require the user to allocate or handle memory. Everything is done by the JVM.
• Secure – Java eliminates security issues such as viruses, eavesdropping, and tampering.
• System Independent – ​
​
Java bytecode is machine (system) independent. This means that code
can run on a wide variety of machines with any processor and operating system.
• Portable – A program is said to be portable if it produces the same result on every machine.
Why pointers are eliminated from Java?
Here's why pointers were removed from Java:
• Pointers confuse programs.
• Pointers can easily crash your program.
For example, the program immediately crashes when two pointers are added. The same thing can
happen if you free memory allocated to one variable and forget to allocate it to another variable.
• Pointers break security. Pointers can be used to develop malicious programs such as viruses and
other hacking programs.
What is the BYTE code?
BYTE code is intermediate level code interpreted by the JVM. You can't run it directly on your
machine. BYTE code is intermediate code between Java programs and operating system (OS)
machine code, available in ".class" files. When a Java program or application is compiled, a ".class"
file is generated. The BYTE code is the same for all operating systems, but the machine code is
different for each operating system.
What is JVM? Explain its working?
A JVM (Java Virtual Machine) is an abstract machine designed to be implemented on existing
processors. Hides the underlying operating system (OS) from Java applications. This is actually the
heart of the entire Java program execution process. Programs written in Java are compiled to Java
bytecode. It is interpreted by a specific Java interpreter for a specific platform. This Java interpreter
is called the "Java Virtual Machine". The JVM's machine language is called Java Byte Code. First, a
Java program is converted into a class file by a Java compiler using bytecode instructions. This
class file is passed to the JVM. The JVM has a module called the class loader subsystem that does
the following:
• First, load the class file into memory.
• Allocate the memory needed to execute the program, if a byte instruction is appropriate.
What is JRE?
JRE stands for "Java Runtime Environment". It is a platform consisting of the Java Virtual Machine,
Java libraries, and all other components required to run Java applications and applets.
What is the Java compiler?
A Java compiler is a program that converts Java source code into Java bytecode. A simple Java
compiler is already included in the JDK (Java Development Kit). The Java compiler invoked by
"javac".
What is the JIT compiler?
The JIT (Just-In-Time) compiler is the part of the JVM that speeds up the execution of Java
programs. A JIT compiler, at runtime he interacts with the JVM. Instead of interpreting bytecode
every time a method is called, the JIT compiles the bytecode into machine code instructions for the
running machine and then calls the object code. This prevents the JVM from repeatedly interpreting
the same sequence of bytecodes, speeding up execution.
What is public static void main (String args []) in Java?
The public static void main (String [] args) line defines the method main. Conceptually, it is similar to
the main () function in C/C++. In Java, main () is the entry point for all Java programs. A Java
program can have any number of classes, but only one of them must contain the method that
initiates execution. This line contains the following terms:
public - The term "public" is an access identifier. Declare the main method as unprotected and make
it accessible from all other classes.
Static - The term "static" declares the method as belonging to the class as a whole rather than being
part of the class's objects.
main () should always be declared as "static" because the interpreter uses this method before
creating the object.
void - The void type qualifier indicates that the main method does not return any value, it just prints
statements to the screen.
main () - This is the method where the interpreter starts executing the program. This is actually the
name of the method the Java Virtual Machine is looking for as a starting point for applications with a
particular signature. String args [] - This is the parameters passed to the main method.
What happens if string args [] is not written in the main ()
method?
If you write the main () method without the string args [] . B. public static void main (), the code
compiles, but the JVM doesn't run the code because it can't recognize the main () method as the
one that starts running the Java program. Note that the JVM always looks for a main () method with
a string array as a parameter.
Is Java 100% Object-oriented? Also, give a reason.
Java is not 100% object oriented as it supports non-primitive data types that are not objects.
Concepts like polymorphism, inheritance, abstraction, mainly his OOP concepts make Java an
object-oriented language. However, it does not support all OOP concepts such as multiple
inheritance.
What are the types of Java programs?
There are two main types of Java programs:
(i) internet applets and (ii) standalone applications.
Internet Applets - Internet applets are small programs embedded in web pages that run securely on
a variety of computers with a Java-enabled browser (with limited access to system resources).
Internet applets cannot run by themselves. They can only be run within a web browser.
Standalone Applications - Standalone applications are much more interesting than Internet
applets. These are just software applications that don't require low-level operating system (OS) or
hardware access. This type of Java program includes most common desktop applications such as
word processors and spreadsheets. All Java standalone applications start by executing the main ()
method. Java standalone applications can run independently on any platform
What are the different levels of access protection (access
modifiers) available in Java?
Access modifiers are a special kind of keyword essentially used to restrict access to classes,
constructors, data members, and methods of another class.
Java has four basic types of access modifiers:
Private - Private members of a class cannot be accessed anywhere outside the class. They can
only be accessed within the class via the methods of that class.
Public - Public members of a class are accessible anywhere outside the class. So other programs
can read and use them.
Protected - Protected members of a class can be accessed outside the class, but are typically in the
same directory.
Default - If the programmer does not write an access modifier/specifier, the Java compiler will use
the default access specifier. "Standard" members are accessible outside the class but within the
same directory.
Define ‘packages. What are some advantages of packages?
A package represents a directory or container that contains a set of related classes and interfaces.
The functionality of the objects determines how they are grouped.
Package Benefits:
• Packages help group related classes and interfaces together.
• Packages hide classes and interfaces in separate subdirectories to prevent accidental deletion of
classes and interfaces.
• Classes and interfaces in one package are separated from classes and interfaces in another
package.
How many types of packages are used in Java?
(i) Built-in packages :
Packages already provided in the Java language. These packages provide programmers with all the
classes, interfaces, and methods they need to perform their tasks.
Some important packages are:
• java. lang: "lang" represents the language. This package contains the main classes and interfaces
essential for developing basic programs.
• java. util: "util" stands for utility. This package contains useful classes and interfaces such as
Stack, LinkedList, Vector, and Array. A class is called a collection.
• java.io: "io" stands for "input and output". This package contains streams classes. A stream
represents the flow of data from one place to another.
(ii) Custom Packages Similar to the built-in packages, users can also create their own packages.
Such packages are called custom packages.
What are the different types of memory areas used by JVM?
The following types of memory regions are allocated by the JVM: Heap: The heap area is the
run-time data area where memory is allocated for objects. Stack: Java stack save frame. Stores
local variables and partial results. The Java stack is responsible for calling and returning methods. A
private JVM stack is also created for each thread each time it is created. A new frame is created
each time the method is called and ends when the method call completes.
What are the Wrapper classes?
As the name suggests, wrapper classes are used to wrap primitive data types into objects of that
particular class. Simply put, wrapper classes are used to convert Java primitives to reference types
(objects). These are typically object representations for all eight commonly used primitives in Java.
In Java, all wrapper classes are immutable and final.
👉Core Java Interview Questions and Answers for Freshers
👉Important Core Java Interview questions and answers
👉Java Exception handling Interview Questions and Answers
👉Oops Interview Questions in Java for Freshers
👉Java Collection Framework Interview questions for Freshers
👉Java9 Interview Questions & Answers for beginners
👉Java8 Interview Questions & Answers for beginners

More Related Content

Similar to Top 10 Important Core Java Interview questions and answers.pdf

1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
Madhura Bhalerao
 
CORE JAVA
CORE JAVACORE JAVA
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
Nanthini Kempaiyan
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
Harsha Batra
 
java slides
java slidesjava slides
java slides
RizwanTariq18
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
DrPreethiD1
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
gowher172236
 
Java introduction
Java introductionJava introduction
Java introduction
logeswarisaravanan
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
Qualys
 
Java-1st.pptx about Java technology before oops
Java-1st.pptx about Java technology before oopsJava-1st.pptx about Java technology before oops
Java-1st.pptx about Java technology before oops
buvanabala
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
vmadan89
 
What is-java
What is-javaWhat is-java
What is-java
Shahid Rasheed
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
Nexus
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
Daroko blog(www.professionalbloggertricks.com)
 
Java-Unit-I.ppt
Java-Unit-I.pptJava-Unit-I.ppt
Java-Unit-I.ppt
RameswarGprec
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
RahulAnand111531
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
WE-IT TUTORIALS
 

Similar to Top 10 Important Core Java Interview questions and answers.pdf (20)

1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
java slides
java slidesjava slides
java slides
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
 
Java introduction
Java introductionJava introduction
Java introduction
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
 
Java-1st.pptx about Java technology before oops
Java-1st.pptx about Java technology before oopsJava-1st.pptx about Java technology before oops
Java-1st.pptx about Java technology before oops
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
What is-java
What is-javaWhat is-java
What is-java
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java basics notes
Java basics notesJava basics notes
Java basics notes
 
Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)Java programming basics notes for beginners(java programming tutorials)
Java programming basics notes for beginners(java programming tutorials)
 
Java 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENTJava 3 rd sem. 2012 aug.ASSIGNMENT
Java 3 rd sem. 2012 aug.ASSIGNMENT
 
Java-Unit-I.ppt
Java-Unit-I.pptJava-Unit-I.ppt
Java-Unit-I.ppt
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
 

Recently uploaded

FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 

Top 10 Important Core Java Interview questions and answers.pdf

  • 1. What is Java? Java is a platform-independent, high-level, object-oriented, multithreaded, portable programming language. It was originally designed by James Gosling of Sun Microsystems in June 1991. Released in 1995 as a core component of Sun Microsystems. Sun Microsystems was then acquired by Oracle, and Java was developed by Oracle. Currently Java is one of the most popular programming languages ​ ​ in the world. It is also considered a platform independent because it has its own JRE and API. What are the main features of Java? The main Java features/properties are: • Object Oriented - Java is an object-oriented programming language. This because Java programs use classes and objects. • Distributed - Information is distributed among different computers on the network. • Rugged - Rugged means strong. Java programs are robust and do not crash as easily as C or C++ programs. There are two reasons. First, Java has excellent built-in exception handling capabilities, and second, memory management capabilities. Most 'C' and 'C++' programs crash prematurely because they don't allocate enough memory. Java does not have this problem because it does not require the user to allocate or handle memory. Everything is done by the JVM. • Secure – Java eliminates security issues such as viruses, eavesdropping, and tampering. • System Independent – ​ ​ Java bytecode is machine (system) independent. This means that code can run on a wide variety of machines with any processor and operating system. • Portable – A program is said to be portable if it produces the same result on every machine. Why pointers are eliminated from Java?
  • 2. Here's why pointers were removed from Java: • Pointers confuse programs. • Pointers can easily crash your program. For example, the program immediately crashes when two pointers are added. The same thing can happen if you free memory allocated to one variable and forget to allocate it to another variable. • Pointers break security. Pointers can be used to develop malicious programs such as viruses and other hacking programs. What is the BYTE code? BYTE code is intermediate level code interpreted by the JVM. You can't run it directly on your machine. BYTE code is intermediate code between Java programs and operating system (OS) machine code, available in ".class" files. When a Java program or application is compiled, a ".class" file is generated. The BYTE code is the same for all operating systems, but the machine code is different for each operating system. What is JVM? Explain its working? A JVM (Java Virtual Machine) is an abstract machine designed to be implemented on existing processors. Hides the underlying operating system (OS) from Java applications. This is actually the heart of the entire Java program execution process. Programs written in Java are compiled to Java bytecode. It is interpreted by a specific Java interpreter for a specific platform. This Java interpreter is called the "Java Virtual Machine". The JVM's machine language is called Java Byte Code. First, a Java program is converted into a class file by a Java compiler using bytecode instructions. This class file is passed to the JVM. The JVM has a module called the class loader subsystem that does the following: • First, load the class file into memory. • Allocate the memory needed to execute the program, if a byte instruction is appropriate.
  • 3. What is JRE? JRE stands for "Java Runtime Environment". It is a platform consisting of the Java Virtual Machine, Java libraries, and all other components required to run Java applications and applets. What is the Java compiler? A Java compiler is a program that converts Java source code into Java bytecode. A simple Java compiler is already included in the JDK (Java Development Kit). The Java compiler invoked by "javac". What is the JIT compiler? The JIT (Just-In-Time) compiler is the part of the JVM that speeds up the execution of Java programs. A JIT compiler, at runtime he interacts with the JVM. Instead of interpreting bytecode every time a method is called, the JIT compiles the bytecode into machine code instructions for the running machine and then calls the object code. This prevents the JVM from repeatedly interpreting the same sequence of bytecodes, speeding up execution. What is public static void main (String args []) in Java? The public static void main (String [] args) line defines the method main. Conceptually, it is similar to the main () function in C/C++. In Java, main () is the entry point for all Java programs. A Java program can have any number of classes, but only one of them must contain the method that initiates execution. This line contains the following terms: public - The term "public" is an access identifier. Declare the main method as unprotected and make it accessible from all other classes. Static - The term "static" declares the method as belonging to the class as a whole rather than being part of the class's objects.
  • 4. main () should always be declared as "static" because the interpreter uses this method before creating the object. void - The void type qualifier indicates that the main method does not return any value, it just prints statements to the screen. main () - This is the method where the interpreter starts executing the program. This is actually the name of the method the Java Virtual Machine is looking for as a starting point for applications with a particular signature. String args [] - This is the parameters passed to the main method. What happens if string args [] is not written in the main () method? If you write the main () method without the string args [] . B. public static void main (), the code compiles, but the JVM doesn't run the code because it can't recognize the main () method as the one that starts running the Java program. Note that the JVM always looks for a main () method with a string array as a parameter. Is Java 100% Object-oriented? Also, give a reason. Java is not 100% object oriented as it supports non-primitive data types that are not objects. Concepts like polymorphism, inheritance, abstraction, mainly his OOP concepts make Java an object-oriented language. However, it does not support all OOP concepts such as multiple inheritance. What are the types of Java programs? There are two main types of Java programs: (i) internet applets and (ii) standalone applications. Internet Applets - Internet applets are small programs embedded in web pages that run securely on a variety of computers with a Java-enabled browser (with limited access to system resources). Internet applets cannot run by themselves. They can only be run within a web browser.
  • 5. Standalone Applications - Standalone applications are much more interesting than Internet applets. These are just software applications that don't require low-level operating system (OS) or hardware access. This type of Java program includes most common desktop applications such as word processors and spreadsheets. All Java standalone applications start by executing the main () method. Java standalone applications can run independently on any platform What are the different levels of access protection (access modifiers) available in Java? Access modifiers are a special kind of keyword essentially used to restrict access to classes, constructors, data members, and methods of another class. Java has four basic types of access modifiers: Private - Private members of a class cannot be accessed anywhere outside the class. They can only be accessed within the class via the methods of that class. Public - Public members of a class are accessible anywhere outside the class. So other programs can read and use them. Protected - Protected members of a class can be accessed outside the class, but are typically in the same directory. Default - If the programmer does not write an access modifier/specifier, the Java compiler will use the default access specifier. "Standard" members are accessible outside the class but within the same directory. Define ‘packages. What are some advantages of packages? A package represents a directory or container that contains a set of related classes and interfaces. The functionality of the objects determines how they are grouped. Package Benefits:
  • 6. • Packages help group related classes and interfaces together. • Packages hide classes and interfaces in separate subdirectories to prevent accidental deletion of classes and interfaces. • Classes and interfaces in one package are separated from classes and interfaces in another package. How many types of packages are used in Java? (i) Built-in packages : Packages already provided in the Java language. These packages provide programmers with all the classes, interfaces, and methods they need to perform their tasks. Some important packages are: • java. lang: "lang" represents the language. This package contains the main classes and interfaces essential for developing basic programs. • java. util: "util" stands for utility. This package contains useful classes and interfaces such as Stack, LinkedList, Vector, and Array. A class is called a collection. • java.io: "io" stands for "input and output". This package contains streams classes. A stream represents the flow of data from one place to another. (ii) Custom Packages Similar to the built-in packages, users can also create their own packages. Such packages are called custom packages. What are the different types of memory areas used by JVM? The following types of memory regions are allocated by the JVM: Heap: The heap area is the run-time data area where memory is allocated for objects. Stack: Java stack save frame. Stores local variables and partial results. The Java stack is responsible for calling and returning methods. A
  • 7. private JVM stack is also created for each thread each time it is created. A new frame is created each time the method is called and ends when the method call completes. What are the Wrapper classes? As the name suggests, wrapper classes are used to wrap primitive data types into objects of that particular class. Simply put, wrapper classes are used to convert Java primitives to reference types (objects). These are typically object representations for all eight commonly used primitives in Java. In Java, all wrapper classes are immutable and final. 👉Core Java Interview Questions and Answers for Freshers 👉Important Core Java Interview questions and answers 👉Java Exception handling Interview Questions and Answers 👉Oops Interview Questions in Java for Freshers 👉Java Collection Framework Interview questions for Freshers 👉Java9 Interview Questions & Answers for beginners 👉Java8 Interview Questions & Answers for beginners