Java Interview Answers

3 min
10
0
0
Published on updated on
  1. What is a transient variable?

    A transient variable is a variable that may not be serialized.

  2. What is the difference between Abstract class and Interface?

    An abstract class may contain code in method bodies, which is not allowed in an interface. With abstract classes, you have to inherit your class from it and Java does not allow multiple inheritance. On the other hand, you can implement multiple interfaces in your class.

  3. What is the difference between string and string buffer?

    String objects are immutable. StringBuffer supports mutable string.

  4. Is null a keyword?

    According to the Java Language Specification, null, true, and false are technically literal values (sometimes referred to as manifest constants) and not keywords.

  5. What is the difference between multi-threading and multi-processing?

    Multithreading is the ability to perform different tasks of a process simultaneously. This is achieved by using a separate thread for each task. Though there are several threads in a process, at a time the processor will handle only a single thread. Though it appears to be concurrent processing to the end user, internally only single thread will be running. Processor is able to multitask by switching between the threads.

    When it comes to Multiprocessing there will be more than one processor and each thread will be handled by a different processor. Thus leading to concurrent processing of tasks.

  6. What is the difference between equals() method and ==?

    The == operator checks to see if two objects are exactly the same object. Two strings may be different objects, but have the same value.The .equals() method to compare strings for equality(content).

  7. What is JVM?

    JVM is a platform-independent programming language that converts Java bytecode into machine language and executes it.

  8. What are class variables and instance variables?

    Class variable is the variable used in the class, ie class members. Instance variables are the class objects

  9. What is synchronization and why is it important?

    Synchronization is the way to make our program safe. It is used in multithreading. As we know when we have two or more threads that share a common code there can be some problem like inconsistent of data if one thread is updating data in that code. So if we make that sharable code (common code) synchronized then it ensures that at a given time only one thread will be having rights to access that code. Other threads can’t access the code until its free.

  10. How can you force garbage collection?

    You can’t force GC, but could request it by calling System.gc(). JVM does not guarantee that GC will be started immediately.

  11. What’s the difference between constructors and other methods?

    Constructors must have the same name as the class and cannot return a value. They are only called once while regular methods could be called many times.

  12. Explain the usage of Java packages.

    This is a way to organize files when a project consists of multiple modules. It also helps resolve naming conflicts when different packages have classes with the same names. Packages access level also allows you to protect data from being used by the non-authorized classes.

    Click on the link to search and apply for Java jobs

    Answers sourced from www.geekinterview.com and www.techinterviews.com

Continue reading around the topics :

Comment

In the same category

The best IT jobs for introverts IT Career Advice
Introverts can thrive in IT jobs that require focus, problem-solving, and independent work. There are plenty of roles perfect for those who prefer working behind the scenes.
4 min
data jobs in the UK IT Career Advice
Data jobs in the UK are in high demand, with roles in data science, engineering, and analysis offering excellent career stability. From junior data analysts to senior roles like chief data officer, these positions provide clear growth opportunities with salaries ranging from £25,000 to £100,000+
3 min
Preparing for your Junior Data Analyst interview IT Career Advice
Interviews for a Junior Data Analyst role can be challenging, but preparation is key. Be ready to discuss tools like Excel, SQL, and Python, and share how you've used them in projects. This guide covers key questions and tips to help you feel confident.
4 min

Connecting Tech-Talent

Free-Work, THE platform for all IT professionals.

Free-workers
Resources
About
Recruiters area
2024 © Free-Work / AGSI SAS
Follow us