Most Frequently Asked Java Interview Questions.

Vishal Jain
5 min readJun 16, 2018

Here, I am happy to share almost covered both simple and advanced level of java questions for both interviewee and interviewer.

  1. Difference between static and non-static methods, variables And explain their memory architecture as well?
  2. What do you understand by using of final keyword with classes and variables as well, give the case where you will prefer to use the final keyword?
  3. What is typecasting? Suppose there is a data which is of type double then how can you show that double in int data type?
  4. What are the main advantages of polymorphism? And what is the alternate of polymorphism?
  5. What is constructor chaining in java?
  6. Explain constructor with the help of inheritance?
  7. ‘Super’ keyword is used to access superclass properties, but what when you are not allowed to use super then how can you access the property of superclass, if yes then how?
  8. Suppose you have 11th, 12th class books in your beg, now how will you use inheritance to show the relationship between them?
  9. Why java compiler needs main method static only?
  10. What do you understand by anonymous word? And what is the impact of anonymous array and object in java? Explain memory structure with or without anonymous?
  11. Why java requires inner class? What do you understand by static inner classes in java? And where will you use a static and non-static class?
  12. An abstraction is hiding information in java, how java showing abstraction and write a program where you have to show abstraction and do the same program without abstraction?
  13. What are different ways to create an object in java? And what do you understand by object creation in java? Where the memory will be allocated when the object is created in java?
  14. JVM is compiler in java to run your program, explain steps from writing your code to execute on the machine?
  15. What is heap memory allocation in java? Explain the difference between stack and heap memory allocation in java?
  16. How JVM knows about your program and what is the cycle of code execution in java?
  17. Difference between public, private and protected modifiers and explain why do you need all these modifiers in your code?
  18. What will be the result If java set the main method to private?
  19. What is command line argument and how can you give order to java program to execute a file reading operation by command line argument?
  20. Where do you need super constructor and suppose you don’t have super constructor then is there any way to execute superclass constructor, if yes then explain?
  21. The interface is about 100% abstraction, what do you understand by 100% abstraction and how can you achieve 100% abstraction in java? Write the same program from both interface and abstract class, now as you can write the same code with abstract class then why do you need an interface in java?
  22. What is multilevel inheritance in java? And does java support multiple inheritances, explain your thoughts?
  23. Java is object-oriented language, explain both object and oriented word?
  24. What do you understand by design patterns in oops, if you have to design your own patterns then what are the parameters you will consider most?
  25. Write some basic programs like: <1>. Palindrome,< 2>. String reverse, <3>. Patterns of stars in all possible ways, <4>.Find out minimum and maximum numbers in a given array, <5>. You are given city name and person name blank array of fixed-sized, write a program to get the city name of a person. You have to take city name and person name at run time, <6>. Write matrix multiplication program in java, <7>. How will you break an array in an equal part? Consider all possible cases, <8>. Write a program using switch case where you have to ask day name from the user and then you will print the first three letters of that day in the capital letter as a response to the user,<9>. Ask the user to give a string as input then show repeated letters with count as a response, <10>. Convert any given number into binary format, <11>. Read context from a file and replace every small letter into capital and every capital letter into the small letter and then print the modified file as the response of program,<12>. Write a program where the program will ask the user about name, age, address and college name, then you will print the detail in order but if user repeats the same name again then show available data of the user.
  26. What do you understand by the break and continue keyword in an iteration?
  27. Write all possible syntax of for loop?
  28. What is the difference between while and for loop? And explain the cases where which one suits better?
  29. What do you understand by variable scope? Is it required to initialize the local variable explain why so?
  30. What is an interpreter in java? And the difference between compilation and interpretation in java?
  31. What do you get by mean of return type in java? And suppose you have to return int data but return type of method is double, explain will it work or not?
  32. Whether you can override superclass methods or variables? Explain it?
  33. What is object chaining in java?
  34. Difference between parameters and arguments in java?
  35. Write a singleton class in java? And where, why you will prefer singleton in any case?
  36. As java have multi-threaded programming nature, first explain what is it? Then : <1>.Why do you need it? <2>.Explain and write every possible case to create a thread in java? ❤>What is thread sleeping mean in java?<4>.Suppose you have two different files at any location then write a program with two threads where every single thread will read and print single file but both will do the operation at the same time. So file 1 will be read by thread 1 and file 2 will be read by thread 2. <5>. Explain thread architecture in java? <6>. What is thread pooling in java? <7>. Read some basic function related to multithreading in java.
  37. Whether java is procedural language or functional language explain it?
  38. What are the parameters that make java different from other language give some practical examples where java suits better than any other language?
  39. Why exception handling is introduced in java? List down all the causes behind this?
  40. Let's consider java is not having error handling mechanism then write a function where you need to handle ArrayIndexOutOfBoundException yourself.
  41. Difference between try, catch and finally?
  42. Consider your body as a task and then design every body part as per oops concept. (think as per your convenience).
  43. Try to relate every oop concept from your surrounding.

thanks

Vishal

More where this came from

This story is published in Noteworthy, where thousands come every day to learn about the people & ideas shaping the products we love.

Follow our publication to see more stories featured by the Journal team.

--

--

Vishal Jain

Software should make our surrounding better. So working on it.