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
1. What is Abstraction ?
2. What is concept of OOPS ?
3. Why Java is object oriented programming ?
4. What is Encapsulation ?
5. What is Inheritance ?
6. What is Polymorphism ?
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