banner-image

4.6 Created by potrace 1.15, written by Peter Selinger 2001-2017

5.0 Created by potrace 1.15, written by Peter Selinger 2001-2017

4.6 Created by potrace 1.15, written by Peter Selinger 2001-2017

Java Interview Questions Java FAQ


Hi, Welcome to Monopoly IT Solutions, our Interview Questions / FAQs can be very helpful for interview preparation in several ways:

  • Understanding the way how Questions are asked by interviewer
  • Practicing Answers, find our appropriate ways of answeringand excel the interview
  • Gaining Insight into the industry standard
  • Reducing Anxiety of Interview
  • Self analysis of Key Skills

Following are the conceptual theory questions

  • The two types of exceptions in Java are:
  • 1. Checked Exception:Must be handled at compile-time(eg:`IO Exception).
  • 2. Unchecked Exceptions: Occur at runtime and don’t require handling at compile-time (e.g., `NullPointerException`).

  • The JVM (Java Virtual Machine is an engine that runs Java bytecode on any device). Java is called "Platform Independent" because the JVM enables Java code (compiled into bytecode) to run on any operating system without modification, as long as the system has a compatible JVM.

  • JDK (Java Development Kit):
    A full development kit that includes tools for developing Java applications, such as the compiler, debugger, and libraries. It includes the JRE.
  • JRE (Java Runtime Environment):
    Provides libraries and the JVM needed to run Java applications but lacks development tools like the compiler

  • Applet: A small Java program that runs in a web browser and requires a Java plugin. It has restricted access to system resources for security.
  • Java Apllication: A standalone program that runs directly on the Java platform (using JRE) with full access to system resources.

  • Servlet:is a Java class used to handle requests and responses on a server, typically to create dynamic web content. It runs on a web server and processes client requests (usually HTTP), generating a response (such as HTML).

  • JSP Page: A Java Server Page (JSP) is a server-side technology used to create dynamic web content. It’s compiled into a servlet and runs on a web server.

  • HashMap:HashMap stores key-value pairs, using hashing for fast access. Keys are hashed to find bucket locations, allowing fast retrieval.

  • Java Data Types: Includes primitive types (int, float, char, etc.) and reference types (classes, interfaces, arrays).

  • Autoboxing/Unboxing: Autoboxing automatically converts primitives to wrapper types, while unboxing converts wrappers back to primitives.

  • Static Keyword: Indicates a member belongs to the class itself, rather than instances, and can be accessed without creating an object.

  • Iterator: An interface to traverse a collection one element at a time, with methods like next(), hasNext(), and remove().

  • Garbage Collection: Automatically frees memory by destroying unreachable objects, helping to manage memory usage.

  • Garbage Collection Eligibility: An object becomes eligible for garbage collection when it is no longer reachable by any references.

  • Finally Block: Executes code after a try-catch block, regardless of exceptions, ensuring essential cleanup.

  • Method Overriding/Overloading:Overloading is defining methods with the same name but different parameters; overriding is redefining a superclass method in a subclass.

  • JDBC: Java Database Connectivity, an API for connecting and executing queries on a database.

  • JSP Actions: Special tags in JSP for common functions, like <jsp:include>to include content.

  • Swing Design Pattern:Swing Design Pattern: MVC (Model-View-Controller) pattern, separating UI (View), logic (Controller), and data (Model).

  • ExpressionsCode constructs that return a value, e.g., a + b.

  • Reflection:Allows inspection and manipulation of classes, fields, methods at runtime; useful for dynamic code and libraries.

  • Constructor:Initializes an object; types are default (no arguments) and parameterized (with arguments).

  • finally vs. finalize():finally handles cleanup after a try block; finalize() is a method called by the garbage collector before an object is destroyed.

  • Java Heap Structure: Divided into Young Generation (new objects), Old Generation (aged objects), and Permanent Generation (class metadata).

  • Throw vs. Throws: throw explicitly throws an exception; throws declares exceptions a method can throw.

  • Iterator vs. ListIterator: Iterator traverses forwards; ListIterator can traverse both directions and modify elements.

  • No, you cannot access non-static variables in a static context directly.

  • ArrayList vs. LinkedList: ArrayList uses a dynamic array, better for indexing; LinkedList uses nodes, better for frequent insertions/deletions.

  • Deadlock: Occurs when two or more threads are blocked, each waiting for the other to release resources.

  • Array vs. ArrayList:Arrays are fixed-size; ArrayLists are dynamic-size and part of the Java Collections Framework.

  • Applet vs. Servlet: Applet runs on the client side (browser); Servlet runs on the server side (web server).

  • Servlet Life Cycle:: init() initializes, service() handles requests, destroy() cleans up

  • Server Side Include (SSI): A server directive to include content (e.g., HTML snippets) into web pages

  • JSP Advantages: Easier to write than servlets for dynamic web content, integrates with HTML, supports Java syntax

  • JIT:Just-In-Time compiler, part of JVM that compiles bytecode to machine code at runtime for performance

  • Enum Extension: No, enums cannot be extended as they are implicitly final.

  • Java ClassLoader: Loads Java classes at runtime into the JVM, enabling dynamic loading.

  • Pass-by-Value: Java passes arguments by value, meaning copies of primitive values or references to objects are passed.

  • Final vs. Finalize vs. Finally: final for constants, finalize() for cleanup before GC, finally for try-catch completion.

  • Synchronized Method vs. Block: Synchronized method locks the whole method, while a synchronized block only locks specific code.

  • Thread-Safety of Enum: Enums are inherently thread-safe due to their immutability and single-instance nature.

Following are the coding based questions

  • 
                                                                                                                                                                                          
                                                                                                                                                                                          

  • 
                                                                                                                                                                                      
                                                                                                                                                                                      

  • 
                                                                                                                                                                                  
                                                                                                                                                                                  

  • 1
    2 3
    4 5 6
    7 8 9 10
    11 12 13 14 15
  • 
                                                                                                                                                                              
                                                                                                                                                                              

  • 
                                                                                                                                                                                  
                                                                                                                                                                                  

  • 
                                                                                                                                                                                                          
                                                                                                                                                                                                          

  • 
                                                                                                                                                                                                          
                                                                                                                                                                                                          

  • Original Array:
    10 20 30
    40 50 60
    After changing the rows and columns of the said array:10 40
    20 50
    30 60
    
                                                                                                                                                                                                          
                                                                                                                                                                                                          

  • Note: One inch is 0.0254 meter
    Test Data
    Input a value for inch: 1000
    Expected Output :
    1000.0 inch is 25.4 meters
    
                                                                                                                                                                                                          
                                                                                                                                                                                                          

  • 
                                                                                                                                                                                                          
                                                                                                                                                                                                          

getintouch

Book for Live Demo!