Skip to main content

Core Java Interview Question for Experienced Candidate

Core Java Interview Question for an experienced candidate

Top 20 Java Interview Question, Check Your Java Skills.

1)  What is annotation in Java, How we can create custom annotation?
2)  What is Reflection API in Java?
3)  How we can create Checked User Define Exception and  Unchecked User Define Exception?
4)  What is Inner class, Local Inner Class, Static Inner Class, Anonymous Class
5)   What is a Generic Class in Java  How we can define Custom Generic Class
6)  How we can Synchronize Array List?
7)   Which is the best Collection class to add and edit elements concurrently?
8)   What is the Marker interface, the difference between annotation and marker Interface?
9)    What will be the output when we call run() manually in Thread?
10)   What is the Design pattern in Java define Creational, Behavioral, and Structural Design Pattern?
11)    Difference between Comparable and Comparator?
12)  What is the final class in java, provide the name of predefined Final Class in java?
13)   What is Singleton Class in Java?
14)    A map is the part of the Collection Framework or not?
15)   What is dependency Injection in Java?
16)   What new features added in Interface in Java?
17)     What is the Difference between System.out and Console?Write() in Java?
18)    What is Lambda expression and foreach() in Java?
19)    What is the difference between volatile and Transient modifiers in java?
20)   If we did not know the datatype of the column in ResultSet then which method will work to show data?
21) What is the difference between “==” and “equals(…)” in comparing Java String objects?
22) In Java, what purpose do the key words final, finally, and finalize fulfill?
23) When you have automatic memory management in Java via GC, why do you still get memory leaks in Java?
24)  What are the differences between Heap and Stack Memory in Java?
25) What is Java String Pool?
26) What is a classloader in Java?
27) What is the difference between abstract classes and interfaces?
28) Can you override a private or static method in Java?
29) What is an association, aggregation, composition in JAVA?
30) What is object cloning in Java?
31) What is Request Dispatcher?
32) What are the different methods of session management in servlets?

 

Comments

  1. Q1). What is annotation in java.How we can create custom annotataion?
    Ans). Annotation is a tag that represent the metadata. Attached with class,interface,methods or fields to indicate some additional information which can be used by java compiler and jvm.
    Q2). What is Reflection API in java?
    Ans). Reflection is an API which is used to examine or modify the behavior of methods, classes, interfaces at runtime.
    • The required classes for reflection are provided under java.lang.reflect package.
    • Reflection gives us information about the class to which an object belongs and also the methods of that class which can be executed by using the object.
    • Through reflection we can invoke methods at runtime irrespective of the access specifier used with them.


    Q3). How to create user define checked or unchecked Exception?
    Ans). User define unchecked Exception:
    class UserDefinedException extends RuntimeException {
    UserDefinedException(String s) {
    super(s);
    }
    }
    User define unchecked Exception:
    class UserDefinedException extends Exception {
    UserDefinedException(String s) {
    super(s);
    }
    }

    Q3 How we can synchronize Array List?
    Ans). We can use Collections class to synchronize array list

    public class SyncronizeArrayList {
    public static void main(String args[]) {

    List fruitList = new ArrayList();

    fruitList.add("Mango");
    fruitList.add("Banana");
    fruitList.add("Apple");
    fruitList.add("Strawberry");
    fruitList.add("Pineapple");


    furitList = Collections.synchronizedList(fruitList);


    synchronized (fruitList) {
    Iterator itr = fruitList.iterator();
    while (itr.hasNext()) {
    System.out.println(itr.next());
    }
    }
    }
    }
    Q4) which is the best collection class is to add and edit elements concurrently?
    Ans). LinkedList is the best class to edit and add the elements because it uses doubly linked list. In Doubly linked list we can add or delete elements at every end.
    Q5) what will be the output when we call run() manuaaly in thread?
    Ans) if we call run() directly then it does not work like thread it can normal work.


    ReplyDelete

Post a Comment

POST Answer of Questions and ASK to Doubt

Popular posts from this blog

DSA in C# | Data Structure and Algorithm using C#

  DSA in C# |  Data Structure and Algorithm using C#: Lecture 1: Introduction to Data Structures and Algorithms (1 Hour) 1.1 What are Data Structures? Data Structures are ways to store and organize data so it can be used efficiently. Think of data structures as containers that hold data in a specific format. Types of Data Structures: Primitive Data Structures : These are basic structures built into the language. Example: int , float , char , bool in C#. Example : csharp int age = 25;  // 'age' stores an integer value. bool isStudent = true;  // 'isStudent' stores a boolean value. Non-Primitive Data Structures : These are more complex and are built using primitive types. They are divided into: Linear : Arrays, Lists, Queues, Stacks (data is arranged in a sequence). Non-Linear : Trees, Graphs (data is connected in more complex ways). Example : // Array is a simple linear data structure int[] number...

JSP Page design using Internal CSS

  JSP is used to design the user interface of an application, CSS is used to provide set of properties. Jsp provide proper page template to create user interface of dynamic web application. We can write CSS using three different ways 1)  inline CSS:-   we will write CSS tag under HTML elements <div style="width:200px; height:100px; background-color:green;"></div> 2)  Internal CSS:-  we will write CSS under <style> block. <style type="text/css"> #abc { width:200px;  height:100px;  background-color:green; } </style> <div id="abc"></div> 3) External CSS:-  we will write CSS to create a separate file and link it into HTML Web pages. create a separate file and named it style.css #abc { width:200px;  height:100px;  background-color:green; } go into Jsp page and link style.css <link href="style.css"  type="text/css" rel="stylesheet"   /> <div id="abc"> </div> Exam...

Conditional Statement in Python

It is used to solve condition-based problems using if and else block-level statement. it provides a separate block for  if statement, else statement, and elif statement . elif statement is similar to elseif statement of C, C++ and Java languages. Type of Conditional Statement:- 1) Simple if:- We can write a single if statement also in python, it will execute when the condition is true. for example, One real-world problem is here?? we want to display the salary of employees when the salary will be above 10000 otherwise not displayed. Syntax:- if(condition):    statements The solution to the above problem sal = int(input("Enter salary")) if sal>10000:     print("Salary is "+str(sal)) Q)  WAP to increase the salary of employees from 500 if entered salary will be less than 10000 otherwise the same salaries will be displayed. Solution:- x = int(input("enter salary")) if x<10000:     x=x+500 print(x)   Q) WAP to display th...