Real Java Interview Questions asked in Oracle

Sreenath Ravva, one of the readers of HowToDoInJava, has appeared in an interview in Oracle for a position in the Oracle Enterprise Manager product. The below-listed questions were shared by him so that I can share them with all of you, in hope that it will benefit few of us on any fine day.

I have tried to put links to web pages where you can refer for answers to below interview questions. They may not be enough to cover the topic, but they will give you a start.

1. First Round (Telephonic)

1. Can you please just start telling about yourself and your project?

2. What is abstraction and encapsulation in java ?

3. Method Overloading rules? Can we overload the super class method in sub class. Discussion happened with the example.

4. Method Overriding rules?

5. Widening and narrowing in java? Discussion happened with example?

6. Can I have only try block in code?

No. You need either catch block or finally block along with try block, at least. [Till Java 6]

JDK 7 onwards you can use try-with-resources with “optional” catch or finally block.

try (FileInputStream f = new FileInputStream("temp.json")) 

7. Threads : producer and consumer problem?

8. Why wait(), notify() and notifyAll() are defined in Object class?

9. Can we override wait() or notify() methods?

In, methods getClass(), notify(), notifyAll() and three wait() methods are final, so you can’t override them.

10. Difference between wait(), sleep() and yield()?

11. Explain about join() method in thread class

2. Second Round (Face to Face)

1. Can you just start telling about yourself and your project?

Refer to first question in above list.

2. Have you faced out of memory error? If yes how you fixed ? Tell different scenarios why it comes?

3. Database connection leakage?

Google it.

4. Write a program to swap two numbers with out using third variable?


public class SwappingNumberWithoutThirdVariable
    public static void main(String[] args)throws IOException
        int a = 0 ,b = 1;

        System.out.println("a = "+a);
        System.out.println("b = "+b);

        //Beginning of Swapping
        a = a + b;
        b = a - b;
        a = a - b;
        //End of Swapping

        System.out.println("The numbers after swapping are");
        System.out.println("a = "+a);
        System.out.println("b = "+b);

5. Write a program to sort an array and remove duplicates?

6. Write a program on Singleton?


7. I have two arrays which contains integer. Write a program to merge those two arrays and remove duplicate elements? At the end, I need one array which should have unique elements?

8. Write a program to fetch the data from a table using JDBC and result set?


9. How to get data from HashMap?


10. Difference between Vector and ArrayList?


11. Difference between sleep and wait?


12. Also asked some sql queries.

Practice yourself.

13. Write a program to print Fibonacci series?

public class FibonacciSampleCode
    public static void main(String[] args)
        FibonacciSampleCode fs = new FibonacciSampleCode();
    public void fibonacci()
        int numb1 = 1;
        int numb2 = 1;
        int temp = 0;

        Scanner input=new Scanner(;
        System.out.println("How Many Terms? (Up To 45)");
        int x=input.nextInt();


        for (int i = 0; i < x; i++)
            System.out.println(numb1 + numb2 + " ");
            temp = numb1;
            numb1 = numb2;
            numb2 = temp + numb2;

14. Can we write try catch block like below code?



15. What is the use of finally block?

16. What is the use of final keyword?

17. Can i declare class as static?

18. What is static method and static variable?

19. Can I declare a class as private?

20. What happens if i write return in try block? Will finally executes? What happens if write system.exit(), will finally block executes?

21. Why you want to change the company?

Nobody expects you to tell the truth.. :-)

That’s all interview questions he was able to recall when he wrote me a mail regarding this. We hope that it will help some of us, who are planning our next interview with oracle.

Happy Learning!!

Leave a Reply

Most Voted
Newest Oldest
Inline Feedbacks
View all comments

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions, and frequently asked interview questions.