Skip to main content

Java Interview Questions?

 Java Interview Questions



1. Define Java

Java is a general-purpose, Object-oriented programming and most widely used language which was developed by James Gosling in the 1990s. It’s a system-independent language where one can run the compiled byte code in any other system which contains JRE in it.

2. Explain The Features Of Java

The features of Java include

Platform Independent – The byte code generated on one computer can run on another system.

Robust – Can easily handle errors during execution.

Multithreaded – IT enables users to write programs that can perform many tasks at a time.

Object Oriented – As we know everything in java is an Object.

Performance – The inclusion of JIT Compilers in JRE increases their performance than other programming languages.

3. Define Variables In Java And Their Types.

Variables are the storage locations that are used to store different types of data. In Java, there are three types of variables based on their scope. They are

Local Variables – These are the variables that are declared inside a method

Static Variables – These are the variables when one wants to initialize when the execution of the program starts. They are defined using the static keyword.

Instance Variables – These are defined outside the method but inside the class.

4. Difference Between JDK, JRE, And JVM.

JDK (Java Development Kit) is a Software Development Environment that is used for developing java programs. JRE (Java Runtime Environment) is a space that enables users to execute java programs and JVM (Java Virtual Machine) is responsible for providing the runtime environment in which java compiler-generated byte code can be executed.

5. What Is Meant By JIT Compiler? Define Its Usage

JIT (Just In Time) Compiler is responsible for compiling code at runtime instead of compiling it during the compile time of the programs (also known as Ahead-Of-Time). It improves the performance of java programs by compiling the generated byte code into machine code at run time.

6. What Are Various Access Specifiers In Java?

In general access specifiers when we want to restrict the usage of variables under the scope. Mainly There are three access specifiers in java. They are

Public – These members can be accessible everywhere in the program.

Private – These members are accessible only inside the class.

Protected – These members can be accessed outside the package only with the help of child class.

7. Wrapper Classes In Java?

The main objective of introducing wrapper classes is when one wants to convert primitive data types to object types and vice versa. There are some cases where the util package handles only objects then we need to convert the primitive types to objects using these wrapper classes. The wrapper class for int is Integer, char Character, double-Double, etc.

8. Why The Main Method In Java Is Declared Static?

In Java, the static method is the one that is going to create inside the memory even before initializing the instance(object) of it. So, as we all know that in java the execution starts from the main method, we need to make sure that the main method is called first with the help of declaring it as a static method.

9.  Is It Possible To Execute A Java Program Without The Main Method?

Yes, we can execute the java program without the main method up to JDK 6 by initializing the static block but from JDK version 7 it’s mandatory to include the main method in the java program because the JVM finds the main() method in the program first.

10. Method Overloading In Java?

The process of writing the same method in different ways in a single program is known as Method Overloading in Java. The method can be overloaded in two ways in java one is by changing the number of arguments we are going to pass to that function and another way is to change the data type of the arguments.

11. Constructors And Their Types In Java.

Constructors are special methods in java that are invoked when an object is created instead of explicitly calling like general methods. There are three types of constructors in java

Default Constructor

No argument Constructor

Parameterized Constructor

12. Final Keyword And Its Usage In Java?

The final keyword in java is used when we want to make sure that the state/value of the variable or object Shouldn’t be changed once it’s initialized. So, when a final keyword is used in the declaration of class then no inheritance is possible if we declare a method using the final keyword then that method cannot be overridden and finally the final variable cannot be changed once it was initialized.

13. Is Java A Pure Object-Oriented Language?

No, Java is not a pure object-oriented language. The existence of primitive data types in java language makes it a True Object-oriented language instead of Pure because the primitive data type literals are considered as values not as objects so to convert them to objects, they introduced wrapper classes.

14. Is Java an Object-Oriented Or Object-Based Language? Justify Your Answer.

Java is an object-oriented language because it’s capable of implementing all OOPS concepts when it comes to object-based languages the objects are pre-defined in them instead of creating them explicitly we’ll simply use them. JavaScript is a good example of an Object-based language because even though it has the concept of an object but can’t be able to implement OOPS concepts like Java does.

15. Explain The Singleton Class In Java.

As the name indicates singleton class in java refers to a class that can have a maximum of only one instance (object). The main purpose of introducing them is to restrict the creation of objects.



Comments

Popular posts from this blog

The Ultimate Guide to Pay-Per-Click (PPC) Advertising

  The Ultimate Guide to Pay-Per-Click (PPC) Advertising Introduction In the fast-paced digital marketing world, businesses strive to maximize their online presence and reach their target audiences effectively. One of the most potent tools in their arsenal is Pay-Per-Click (PPC) advertising. This advertising model has revolutionized how companies attract and engage potential customers. This comprehensive guide will delve deep into PPC advertising, exploring its benefits, strategies, and best practices to help you harness its power for your business. What is Pay-Per-Click (PPC) Advertising? PPC advertising is an online marketing model where advertisers pay a fee each time their ad is clicked. Essentially, it's a way of buying visits to your site rather than earning them organically. PPC ads are displayed on search engines, social media platforms, and websites, targeting specific keywords and demographics. The Mechanics of PPC Understanding the mechanics of PPC is crucial for creating...

Difference between loc() and iloc() in Pandas DataFrame

  Difference between loc() and iloc() in Pandas DataFrame Pandas library of python is very useful for the manipulation of mathematical data and is widely used in the field of machine learning. It comprises many methods for its proper functioning.  loc()  and  iloc()  are one of those methods. These are used in slicing data from the Pandas DataFrame. They help in the convenient selection of data from the DataFrame. They are used in filtering the data according to some conditions. The working of both of these methods is explained in the sample dataset of cars. loc()  :  loc()  is label-based data selecting method which means that we have to pass the name of the row or column which we want to select. This method includes the last element of the range passed in it, unlike  iloc() .  loc()   can accept the boolean data unlike  iloc()  .  iloc() :  iloc( )  is an indexed-based selecting method which means that we ...

Best digital marketing in Perth

Best digital marketing in Perth Introduction Your introduction into the brave new world of the digital space will be custom-tailored to your business needs requirements. You will be introduced to the crew who will be handling your project, from inception to the launch into the market. Assess It will be our job to not only know your customers but how they engage with the core products and  brand relationships . From here we break down what we research, to identify the core elements needed to engage the customer. Create It’s imperative that the design of your vessel is done right from the start. Its shape, level of focus, and attention to detail are crucial for a prosperous, lucrative, and extended journey. We will always present concepts and suggestions as per the requirement, but we truly believe this process should be a collaborative one between the creative crew of the PWD and the client. The final form will dictate its progression into the  development  and manufacturi...

Codechef ATM Problem Solve in Python

  Codechef --- ATM Problem Solve in Python Pooja would like to withdraw X $US from an ATM . The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal, the bank charges 0.50 $US. Calculate Pooja's account balance after an attempted transaction. Ex. - Positive integer 0 < X <= 2000 - the amount of cash which Pooja wishes to withdraw. Nonnegative number 0<= Y <= 2000 with two digits of precision - Pooja's initial account balance. Example - Successful Transaction Input: 30 120.00 Output: 89.50 Code :-- total_amount = 120 #int(input("Enter your total avalable account balence:-- ")) cash_withdr = 30 #int(input("How much money do you want :-- ")) check_amount = cash_withdr * 4 if check_amount <= total_amount: now_balence = float(((total_amount - cash_withdr) - 0.50)) print(...

body-fitness Important of life | Comingfly

body-fitness Important of life In general, a strong candidate for the "best" title will be any easy-to-learn exercise that targets multiple muscle groups and gives you the practical strength and muscle tone to meet your fitness goals. Exercises that don't require fancy, expensive equipment earn extra credit. Here are seven of the best exercises for athletes and fitness junkies looking for a simple and effective full-body workout.