Core Java Interview questions included set of questions that is related all core java interview topic separately
Topic 1: Core Java Interview questions on Java main method :
1. What happens if main method is declared as private ?
2. What happens If you do not provide String array as the argument to main method ?
3. Can we overload main() method ?
4. If you do not provide any arguments on the command line, then the String array of Main method will be null or empty ?
5. Why main method is static ?
6. Can we execute a program without main() method ?
7. What happens if the static modifier is removed from signature of main method ?
8. If you need to print “Welcome” without main() method in java class. How will you do this ?
9. Should main() method be compulsorily declared in all Java classes ?
10. What is the return type of the main() method ?
11. What is the argument of main() method ?
12. Can main() method be overloaded ?
13. Can a main() method be declared final ?
14. Does order of public and static declaration matter in main() method ?
15. Is it possible to override the main method ?
16. Can we have multiple main methods in same class ?
17. Can an application have multiple classes having main method ?
18. What is the first argument of the String array in main method ?
19. Explain each keyword of public static void main(String args) ?
Topic 2: Core Java Interview questions on Java abstract class
1. How you define Abstract class ?
2. What is abstract class ?
3. Can there be an abstract class with no abstract methods ?
4. Can we instantiate an abstract class ?
5. What are the differences between Interface and Abstract class ?
6. When you will use abstract classes or interfaces ?
7. When you declare method abstract, can other non abstract methods access it ?
8. What is an Abstract Class and what’s use ?
9. Can you declare abstract class final ?
10. What is use of abstract variable ?
11. Can you create object of abstract class ?
12. What is abstract method ?
14. Can there be any abstract method without abstract class ?
15. Can you use abstract and final both with method ?
16. Can you instantiate the abstract class ?
17. Can we write abstract class without method. If yes what is the use of that ?
Topic 3: Core Java Interview questions on Java interface
1. Can an Interface be defined inside a class ?
2. What is a Marker Interface ?
3. Can Interface be absolutely blank ? What is the use of such an interface ?
4. When can an object reference be cast to an interface reference ?
5. Can we instantiate an interface ?
6. Can anonymous class be declared as implementing an interface and extending a class ?
7. What is interface ?
8. Can you inherit the interface in Java ?
9. Class ABC implements Interface containing method m1 and m2 Class ABC has provided implementation for method m2 Can you create object of Class ABC ?
10. Can method inside Interface be declared as final ?
11. Can Interface implement another Interface ?
12. Can Interface extend another Interface ?
13. Can Class extend more than one Class ?
14. Why Interface can extend more than one Interface but a Class can’t extend more than one Class ?
15. Can Interface be final ?
16. Can class be defined inside an Interface ?
17. What modifiers are allowed for methods in an Interface ?
Topic 4: Core Java Interview questions on Java polymorphism
1. Define principles of OOPS ?
2. How does Java implement polymorphism ?
3. Tell me Polymorphism principle. Explain different forms of Polymorphism ?
4. What is runtime polymorphism or dynamic method dispatch ?
5. Can you achieve Runtime Polymorphism by data members ?
Topic 5: Core Java Interview questions on Java inheritance
1. What is Inheritance ?
2. Explain the Inheritance principle ?
3. Does Java support multiple inheritance ?
4. How do you inherit class can you give examples ?
5. Can one class extend multiple classes and why ?
6. How do you encapsulate properties in inheritance ?
Topic 6: Core Java Interview questions on Java final keyword
1. What is the difference between final, finally and finalize?
2. What do you understand by the Java final keyword?
3. What is the difference between a public and a non-public class?
4. What is the purpose of declaring a variable as final?
5. What is the impact of declaring a method as final?
6. Can you give few examples of final classes defined in Java API?
7. Can you make a constructor final?
8. What it means class or member is final?
9. What is final class?
10. What is blank final variable?
11. Can we initialize blank final variable?
Topic 7: Core Java Interview questions on Java static keyword
1. What is the difference between static and non-static variables ?
2. What is class variables ?
3. When is static variable loaded? Is it at compile time or runtime? When exactly a static block is loaded in Java ?
4. What is static block ?
5. What are static methods ?
6. Can a class be declared as static ?
7. When will you define a method as static ?
8. What are restriction placed on a static method or static block of code ?
9. What is the importance of static variable ?
10. Can we declare a static variable inside a method ?
11. What is the difference between a static and a non-static inner class ?
12. What it means that method or field is static ?
13. What happens to static variable that is defined within method of a class ?
14. How many static initializers you can keep ?
15. What is the difference between static binding and dynamic binding ?
16. What is static import ?
17. Can you declare interface method static?
18. Can we override static method?
19. Why we cannot override static method?
20. What is difference between static (class) method and instance method?
21. What is the difference between inner class and nested class?
22. What is static in java ?
Topic 8: Core Java Interview questions on encapsulation superclass and casting
1. Explain Encapsulation principle ?
2. What is difference between abstraction and encapsulation ?
3. What is data encapsulation ?
4. How you achieve encapsulation in Java ?
5. Which class is super class of every class ?
6. How to invoke super class version of Overridden method ?
7. Does class inherit constructors of its super class ?
8. What is implicit casting ?
9. What is explicit casting ?
10. What is Down-casting ?
11. What is up-casting ?
12. What do you understand by casting in Java language? What are types of casting ?
Topic 9: Core Java Interview questions on Java basic principle
Topic 10: Core Java Interview questions on Java access specifier
1. What are Java Access Specifiers ?
2. What is the difference between public, private, protected and default Access Specifiers ?
3. What is the access scope of a protected method ?
4. Which collection classes provide random access of it’s elements ?
5. What do you understand by modifiers private, protected and public ?
6. If a class is declared without any access modifiers, where may the class be accessed ?
7. What modifiers may be used with an inner class that is a member of an outer class ?
8. What modifiers can be used with a local inner class ?
9. What modifiers may be used with a top-level class ?
10. If method is declared as protected, where may the method be accessed ?
Topic 11: Core Java Interview questions on java overload and override
1. Can method be overloaded based on different return type but same argument type ?
2. What restrictions are placed on method overriding?
3. What are the differences between method overloading and method overriding?
4. Which object oriented concept is achieved by using overloading and overriding?
5. Why does Java not support operator overloading?
6. What restrictions are placed on method overloading?
7. Why isn’t there operator overloading?
8. Why method overloading is not possible by changing the return type in Java?
9. Can overloaded methods be override too?
10. Can we override the overloaded method?
11. How do you prevent a method from being overridden?
12. If you’re overriding the method equals() of an object, which other method you might also consider?
Topic 12: Core Java Interview questions on Java variable and operator
1. What is the difference between declaring variable and defining a variable?
2.How can I swap two variables without using a third variable?
3. What do you understand by a variable?
4. What is transient variable?
5. How to define a constant variable in Java?
6. What is the best practice to declare a java file having only constant ?
7. What is a local, member and a class variable ?
8. If a variable is declared as private, where may the variable be accessed ?
9. What value would the value if String type automatically initialized ?
10. What is the difference between a field variable and a local variable ?
11. What’s initial value of object reference which is defined as an instance variable ?
12. What is the difference between the boolean & operator and the && operator ?
13. How many primitive types available in Java ?
14. To what value is a variable of the boolean type automatically initialized ?
15. Are arrays primitive data types ?
Topic 13: Core Java Interview questions on super keyword and constructor
1. What is super?
2. How are this() and super() used with constructors?
3. Can you use this() and super() both in a constructor?
4. What is Constructor?
5. How does the Java default constructor be provided ?
6. Can constructor be inherited?
7. What is constructor chaining and how is it achieved in Java ?
8. When does the compiler supply a default constructor for a class?
9. Does constructor return any value?
10. What are the differences between Constructors and Methods?
11. Can a constructor be an abstract method ?
Topic 14: Core Java Interview questions on local and instance variable
1. Do interfaces have member variables ?
2. Why there are no global variables in Java ?
3. Can you define private and protected modifiers for variables in interfaces ?
4. What is the default value of the local variables ?
Topic 15: Core Java Interview questions on JVM Java Compiler and Java process
1. What is a JVM ?
2. Can I import same package/class twice? Will the JVM load the package twice at runtime ?
3. Explain working of Java Virtual Machine (JVM) ?
4. Does JVM maintain a cache by itself ? Does the JVM allocate objects in heap ? Is this the OS heap or the heap maintained by the JVM ?
5. Are JVM’s platform independent ?
6. What is difference between JDK,JRE and JVM ?
7. What is phantom memory ?
8. How many types of memory areas are allocated by JVM ?
9. What is JIT compiler ?
10. What do you mean by platform ?
11. What is the main difference between Java platform and other platforms ?
12. What gives Java its ‘write once and run anywhere’ nature ?
13. What is class loader?
14. Is Empty .Java file name a valid source file name?
Topic 16: Core Java Interview questions Java literals and keyword :
1. What is the range Java primitive data types?
2. What are keyword in java ?
3. Is sizeof a keyword in Java?
4. Is null a keyword?
5. Are true and false keywords?
6. Is delete,next,main,exit or null keyword in Java?
Topic 17: Core Java Interview questions miscellaneous
1. What restrictions are placed on the values of each case of a switch statement ?
2. What is the difference between an if statement and a switch statement ?
3. What is meant by pass by reference and pass by value in Java ?
4. What are the differences between == and .equals() ?
5. What is the Java API ?
8. What is the difference between a while statement and a do statement ?
9. What is a native method ?
10. In System.out.println(), what is System, out and println ?
11. How does Java handle integer overflows and underflows ?
12. What type of parameter passing does Java support ?
13. What do you understand by numeric promotion ?
14. How can one prove that the array is not null but empty ?
15. What is Dynamic Binding ?
16. What is object cloning ?
17. What is the most important feature of Java ?
19. What is a pointer and does Java support pointers ?
21. What is difference between Path and Classpath ?
24. Can a source file contain more than one class declaration?
25. I don’t want my class to be inherited by any other class. What should I do ?
26. What is the % operator ?
27. Which class is extended by all other classes ?
28. Which non-Unicode letter characters may be used as the first character of an identifier ?
29. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters ?
30. What restrictions are placed on the location of a package statement within a source code file?
31. What are order of precedence and associativity, and how are they used ?
32. Which characters may be used as the second character of an identifier, but not as the first character of an identifier ?
33. Is the ternary operator written x : y ? z or x ? y : z ?
34. How is rounding performed under integer division ?
35. What are the legal operands of the instanceof operator?
36. What happens when you add a double value to a String?
37. What is the difference between the prefix and postfix forms of the ++ operator?
38. Which Java operator is right associative?
39. Can a double value be cast to a byte?
40. Can a byte value be cast to a double?
41. What is the difference between a break statement and a continue statement?
42. Can a for statement loop indefinitely?
43. What is the difference between the >> and >>> operators?
44. What is difference between object oriented programming language and object based programming language?
45. Can you have virtual functions in Java?
46. What is covariant return type?
47. Are reusable software components written in the Java programming language, designed to be manipulated visually by a software development environment, like JBuilder or VisualAge for Java ?
48. What is package?
49. Do I need to import java.lang package any time? Why ?
50. What is stack and queue ?
51. What is late binding and early binding in java ?
52. What is shallow comparison and deep comparison ?
53. What is lazy loading in Java initialization on demand holder ?
54. What are the different ways to create an object ?
55. How you load the class. What is the mechanism to load the class ?
56. What is volatile variable and why, how it is use in java. Including tell me the details of transient variables also ?
57. What is weak loading ?
58. What is weak hashing ?
59. How can we send the POST request from normal java program ?
60. What are java beans and how different from normal java classes? Can a normal java class can be a bean ?
61. What new functionality you have used from JDK 1.5
Topic 18: Core Java Interview questions on Java Input Output
1. What value read() return when reached end of file?
2. Difference between the Reader/Writer class hierarchy and InputStream/OutputStream class hierarchy?
3. What is Input/Output filter?
4. Why use flush() and close()?
Topic 19: Core Java Interview questions on Serialization and Deserialization
1. What is serialization?
2. What is Deserialization?
3. Difference between Serializalble and Externalizable interface?
4. What is serialization how you achieve the serialization what is the use of serialization
Topic 20: Core Java Interview questions on Java Util Package:
1. What is GregorianCalendar class?
2. What is ResourceBundle class?
3. What is SimpleTimeZone class?
4. What is Locale class?
5. What is reflection API? How are they implemented?
6. What is package?
7. Which package is imported by default?
8. Can class declared private accessed outside its package?
9. What is Externalizable interface?
10. What is Java package and how it is used?
11. What are benefits importing specific class rather than an entire package like import java.net.* VS 12. import java.net.Socket?
13. What is reflection and how we implement it?
14. Can we access private method from outside class?
Topic 21: Core Java Interview questions on JDBC
1. What is JDBC?
2. Why oracle Type 4 driver named oracle thin driver?
3. What is DriverManager class?
4. What is Class.forname why we use?
5. What is JDBC Driver and why need it?
6. How many types of JDBC driver available?
7. What are JDBC and ODBC?
8. What are JDBC interfaces and classes you have used?
9. What are JDBC database naming rules?
10. What are steps write JDBC program?
11. How you handle or iterate ResultSet?
12. What is SQL Java type mapping?
13. What is Scrollable and Updatable ResultSet?
14. How many types of execute queries available?
15. What is DatabaseMetaData?
16. What is ResultSetMetaData?
17. What is Time-out ?
18. What is Prepared statement?
19. What is CallableStatement?
20. How you call store procedure from Java?
21. How you retrieve database information from properties file?
22. How you generate sequence primary key in database?
23. How you store BLOB CLOB Array type object in database?
24. What do you mean by Transaction?
25. What is save point?
26. What is Batch update?
27. What is Rowset?
28. What is JdbcRowSet?
29. What is CachedRowSet?
30. What is WebRowSet?
31. What is there inside WebRowSet xml file?
32. What is FilteredRowSet?
33. What are steps connect to database in java?
34. What is difference between Statement and PreparedStatement interface?
35. How we execute stored procedures and functions?
36. How can we store and retrieve images from database?
Topic 22: Core Java Interview questions on String Handling
1. Convert String to Number using java?
2. What happens if not override equal and hash code in class?
3. Difference between String and StringTokenizer?
4. What is meaning of immutable in String?
5. Why string objects immutable?
6. How many ways to create string object?
7. How many objects created below code?
String s1=”Java Honk”;
String s2=”Java Honk”;
8. Why Java uses concept of string literal?
9. How many objects will be created in following code?
String s=new String(“Java Honk”);
10. What is difference between string and Stringbuffer object?
11. What is difference between StringBuffer and StringBuilder?
12. How can we create immutable class?
13. What is use of toString() method?
14. Define String and its data type?
15. Write method to check if input String is Palindrome?
16. Write method that will remove given character from String?
17. How we make String upper case or lower case?
18. What is String subSequence method?
19. How compare two Strings using java program?
20. How to convert String to char vice versa?
21. How to convert String to byte array vice versa?
22. Can we use String in switch case?
23. Write program to print all permutations of String?
24. Write function to find out longest palindrome in given string?
25. Difference between String StringBuffer and StringBuilder?
26. Why String immutable or final?
27. How to Split String in Java?
28. Why Char array is preferred over String for storing password?
29. How you check if two Strings are equal in Java?
30. What is String Pool?
31. What String intern() method does?
32. Does String thread safe?
33. Why String is popular HashMap key?
Topic 23: Core Java Interview questions on Multithread
1. What you understand by Synchronization?
2. What is thread life cycle?
3. Difference between runnable and Thread class approach?
4. What is multithreading?
5. What is Wait Notify and Synchronize in Threads?
6. Difference between wait() and sleep()?
7. What is locking how many types of locks available?
8. What is objects lock and which objects have locks?
9. What is thread?
10. What is the difference between preemptive scheduling and time slicing?
11. What join() method?
12. Is it possible start thread twice?
13. Can we call run() method instead of start()?
14. What are daemon threads?
15. Can you make user thread daemon thread if thread is started?
16. What is shut down hook?
17. When should we interrupt thread?
18. What is purpose of Synchronized block?
19. Can Java object locked down for exclusive use by given thread?
20. What is static synchronization?
21. What is difference between notify() and notifyAll()?
22. Can method static and synchronized?
23. How you achieve Multi-threading?
24. What is best way to creating a thread and why?
25. Difference between Process and Thread?
26. What are benefits of multithreaded programming?
27. What is difference between user Thread and daemon Thread?
28. How we create Thread?
29. Tell me different states life cycle of Thread?
30. Can we call run() method of Thread class?
31. How you pause execution of Thread for specific time?
32. What you understand about Thread Priority?
33. What is context switching in multithreading?
34. How make sure main() is last thread to finish program?
35. How thread communicate with each other?
36. Why thread communication methods wait() notify() and notifyAll() are Object class?
37. Why wait() notify() and notifyAll() methods should call from synchronized method or block?
38. Why Thread sleep() and yield() methods static?
39. How can we achieve thread safety in Java?
40. What is volatile keyword?
41. Which is more preferred Synchronized method or Synchronized block?
42. How we create daemon thread in Java?
43. What is ThreadLocal?
44. What is Thread Group? Why its advised not use it?
45. What is Java Thread Dump how we get Java Thread dump of Program?
46. What is Deadlock? How to analyze and avoid deadlock situation?
47. What is Java Timer Class? How to schedule task to run after specific interval?
48. What is Thread Pool? How can we create Thread Pool in Java?
Topic 24: Core Java Interview questions on Garbage Collection
1. What is Garbage Collection?
2. What gc() method does?
3. What is purpose of finalize() method?
4. Can unreferenced objects referenced again?
5. What kind of thread is Garbage collector?
Topic 25: Core Java Interview questions on Exception handling
1. What is Exception Handling?
2. What is system and application exception? How you know if its system or application exception?
3. What is exception how you handle exception and what is the best way to handle it?
4. What is difference between Checked Exception and Unchecked Exception?
5. What is base class for Error and Exception?
6. Is it necessary that try block must be followed by catch block?
7. What is finally block?
8. Can finally block used without catch?
9. Is there any case when finally will not be executed?
10. Can exception re-thrown?
11. Can subclass overriding method declare exception if parent class method doesn’t throw exception?
12. What is exception propagation?
13. What two main types of Exceptions? What is difference between compile Time vs. Run Time?
14. What is purpose of Runtime class?
15. How will you invoke any external process in Java?
16. What is Exception in Java?
17. What are Exception Handling Keywords in Java?
18. Explain Java Exception Hierarchy?
19. What are important methods of Java Exception Class?
20. Explain Java multi-catch block?
21. What is difference between Checked and Unchecked Exception in Java?
22. What is difference between throw and throws keyword in Java?
23. How to write custom exception in Java?
24. What is OutOfMemoryError in Java?
25. What are different scenarios causing Exception in thread main?
26. What happens when exception is thrown by main method?
27. Can we have empty catch block?
28. Provide some Java Exception Handling Best Practices?
29. What is the problem with below programs and how do we fix it?
Topic 26: Core Java Interview questions on Inner Class
1. What is nested class?
2. Is there any difference between nested classes and inner classes?
3. Can we access non final local variable inside local inner class?
4. What is nested interface?
Topic 27: Core Java Interview questions on AWT and Swing
1. AWT and Swing
2. Name containers which use Border Layout as their default layout?
3. Which containers use border layout as their default layout?
4. Which containers use FlowLayout as their default layout?
5. What are peerless components?
6. What is difference between Scrollbar and ScrollPane?
7. What is lightweight component?
8. What is heavyweight component?
9. What is applet?
10. Can you write Java class that could be used both as applet as well as application?
Topic 28: Core Java Interview questions on Internationalization
1. What is Locale?
2. How will you load specific locale in Java?
Topic 29: Core Java Interview questions on RMI
1. How can RMI and Corba based applications interact?
Topic 30: Core Java Interview questions on Networking
1. How do I convert a numeric IP address like 18.104.22.168 into a hostname like java.sun.com?