Core Java Interview Quiestions
- Java History and Introduction
- What is java?
- What are java features?
- List the different version of java and which is current version of software
- What is the difference JDK, JRE, JVM and JIT?
- What is JVM? Why is Java called the Platform Independent Programming Language?
- Data type and variables
- What is data type?
- What are the different types of data types?
- List the primitive data types with size and range
- What is a variable?
- What is declaration and initialization variable?
- Explain about local, instance and static variables?
- Can we inherit local variable? If no, why?
- Can we access local variable with object reference?
- Can we declare local variable as static?
- Can we declare local variable as final?
- Can we use any access modifiers on local variable?
- Explain about default value, and list the default value for each primitive data types and what is the default value for non-primitives?
- Will compiler assign a default value to local variable?
- What are pass by reference and pass by value?
- What is the difference between variable and reference variable?
- What is the naming convention fallowed to declare variables (non-constant and constant variables)?
- What is meant be redeclaration and re-initialization, explain?
- Operators
- List the different type of operators that java supports
- What is difference between post and pre increment?
- What is difference between post and pre decrement?
- What is difference between && and & operator (single AND and double AND)?
- What is difference between || and | operator (single OR and double OR)?
- Explain ternary operator with syntax and example
- Condition statement
- What is the syntax of if explain with example?
- What is the syntax of if-else explain with example?
- What is the syntax of else-if explain with example?
- What is nested if explain with example
- Explain switch statement with syntax
- What is the difference between else-if and switch?
- Condition statement
- What is the syntax of if explain with example?
- What is the syntax of if-else explain with example?
- What is the syntax of else-if explain with example?
- What is nested if explain with example
- Explain switch statement with syntax
- What is the difference between else-if and switch?
- Loops
- Explain for loop with syntax
- Explain while loop with syntax
- Explain do-while loop with syntax
- What is the difference between for and while loop?
- What is the difference between do-while and while loop?
- What is break statement and where can we use break statement?
- Methods
- What is a method?
- What are the advantages of method?
- What is method recursion explain with an example?
- Can we have multiple return statements in the method
- Can we return multiple values from the method?
- What is method recursion explain with an example?
- What is the naming convention fallowed to declare method?
- Can we name the method name same as the class name?
- Class and Object
- What is a class?
- What is the object?
- How to create an object?
- Can we create a class as static?
- Can we create a class as final?
- Can we create a class as private?
- Which all access modifiers can be used to declare the class
- What is the naming convention fallowed to declare the class?
- Can a .java file have multiple classes?
- Can we have main method in multiple classes of same .java file? If so, which
main method will get executed?
- What should be the file name, if there are multiple class in a single .java file?
- Can the class name and .java file name be different?
- What is singleton class?
- How can we make a class as singleton?
- What is im-mutable object?
- How can we create a im-mutable class?
- Class members
- What are class members?
- What is a difference between static and non-static members?
- How to access static and non-static members?
- Explain the memory allocation for both static and non-static members?
- When does static members load into memory?
- Can I access the static members using object or reference variable?
- Can we access local variables outside the class? If no, why?
- Can we decalre the local variables as static?
- Blocks
- What is SIB and IIB?
- What is the difference between SIB and IIB?
- Can we have multiple SIB’s and IIB’s in the class? If so, what will the order of
execution?
- If the class contains SIB, IIB and constructor, which will execute first (or order of execution) when we create the first object?
- If there is SIB in main class, which will execute first? SIB or main method
- Can we write SIB inside the method or constructor?
- Inheritance
- What is inheritance?
- Explain inheritance with any inbuilt example
- What are the different types of inheritance explain each with example?
- What are the advantages of inheritance?
- Can we inherit the static members? If no, explain why?
- Can the child class access parent class static members?
- Can we inherit final members of a class?
- Can we inherit the final class?
- Can we inherit the constructor? If no, explain why?
- Can we inherit the private members?
- Can we inherit the blocks?
- Why does java, does not support multiple inheritance?
- Constructor
- What is a constructor?
- What are the different types of constructors?
- What are the advantages of constructor?
- What is parameterized constructor?
- What is the difference between default constructor and zero parameterized
constructor?
- Why do we need a parameterized constructor?
- What is constructor overloading?
- Can we declare the constructor as final?
- Can we declare the constructor as static?
- Can we declare the constructor as abstract?
- Can we declare the constructor as private?
- What is constructor chaining?
- Explain constructor chaining?
- What is the difference between this and super?
- Can a constructor have an empty return statement?
- What will happen if we write a return type to a constructor?
- Can we inherit the constructor? If no, why?
- Can we over-ride the constructor? If no, why?
- What is constructor recursion?
- Abstraction
- What is abstract class?
- What is abstract method?
- Can we create the object of abstract class?
- Can we declare the abstract method as static? If no, why?
- Can we declare the abstract method as final? If no, why?
- Can we declare the abstract method as private? If no, why?
- Can we declare the abstract class final? If no, why?
- Can abstract class have constructor?
- What is the use of abstract class and abstract methods?
- Can an abstract class have only abstract methods?
- Can an abstract class have only concrete methods?
- Can we declare the empty class as abstract?
- Can we achieve 100% abstraction using abstract class?
- Can we have static and non-static members declared in the abstract class? How can we access them?
- What type of variables and methods can be declared inside the abstract class?
- What is interface?
- What type of variables and methods can be declared inside the interface?
- What is functional interface?
- What is marker interface?
- Can we inherit more than one interface to the class?
- Can an interface inherit another interface? If yes, how?
- Can we declare concrete methods inside the interface? If yes, what type of concrete methods can be declared?
- What type of variables can be declared inside the interface?
- Can we override the default methods of interface?
- What type of access modifiers can be used inside the interface?
- What is the difference between abstract class and interface?
- Can we declare the constructor inside the interface? If no, why?
- Can we achieve 100% abstraction using interface? If yes, how?
- What is abstraction?
- What is the advantage of abstraction?
- Polymorphism
- What is polymorphism?
- What is over loading?
- What is over riding?
- What is the difference between over loading and overriding?
- What is dynamic and static binding?
- What is early and late binding?
- What are the rules for overriding?
- Can we override the static method? If no, why?
- Can we override the final method? If no, why?
- Can we overload the static method?
- Can we overload the final method?
- Can we override the main method? If no, why?
- Can we overload the main method? If yes, then which method will be called when we run the program?
- Encapsulation
- What is encapsulation?
- Explain how can we achieve encapsulation in java?
- Give the example for encapsulation?
- Casting
- What is casting?
- What are different types of casting does java support? Explain each with example
- What is implicit casting?
- What is explicit casting?
- What is up-casting?
- What is down-casting?
- What is the use of up-casting?
- Why do we need to do down-casting?
- What is direct down casting? What will happen if we do direct down casting in java without upcasting?
- Can we use parent type reference variable to store the child object? If yes, what is advantage of it?
- Can we store the parent object into child type reference variable?
- When do we get a ClassCastException?
- Access, non-access modifiers and packages
- What are access modifiers?
- What is the use of private, default, protected and public accesses modifiers?
- Can we access protected members outside the package? If yes, how can we access?
- Can we use access modifiers on local variables?
- Can we use access modifiers on blocks?
- What access modifiers can be used to declare the class?
- Why main method should be public?
- What will happen if declare the main method as private?
- What is the use of final keyword?
- What all can be declared as final in java?
- What will happen if we declare the variable as final?
- What will happen if we declare the method as final?
- What will happen if we declare the class as final?
- What is the use of static keyword?
- What can be declared as static in java? What will happen if the member is declared as static?
- What is transient?
- Give an example for inbuilt final classes?
- Give an example for inbuilt abstract classes?
- Object class
- What is Object class?
- What are the different methods present in object class?
- What is the use of toString( ) method?
- How can we compare two objects?
- Why do we need to over-ride the equals() and hashCode() method?
- What is cloning in java?
- How to clone the objects in java?
- What is cloneable?
- What is the difference between == and equals( )?
- What is hash code, in java?
- How to create an object without new keyword?
- What is diamond problem?
- String
- What is String?
- List important String class methods?
- What is the difference between comparing the string object using == operator and equal method?
- Is the String class final? If yes, why is it declared as final?
- What is the difference between String, StringBuffer and StringBuilder?
- Can we override the string class methods? If no, why?
- What is the difference between append and concat method?
- Wrapper class
- What are wrapper class?
- Explain the hierarchy of wrapper class?
- What is boxing?
- What is unboxing?
- What is parsing?
- Can we parse String into char?
- Array
- What is an array?
- How to get the size of array?
- What are the different ways to declare the array?
- What are the advantages of array?
- Why does main method accept String array, and not any other?
- Exception handling
- What is exception?
- How to handle the exception?
- List the exception that you have come across in day-to-day coding along with scenario
- Can we have multiple catch block to single try block?
- Can we have multiple finally block to single try block?
- What is finally?
- Can we have multiple try block to single catch or finally block?
- Can we have try-catch or try-catch-finally block inside a try block?
- Can we have try-catch or try-catch-finally block inside the catch block?
- Can we have try-catch or try-catch-finally block inside the finally block?
- What is a difference between final, finally and finalize?
- Explain about throw keyword
- Explain about throws keyword
- What is the difference between throw and throws?
- What are the different types of Exception?
- What is Runtime Exception / un-checked Exception?
- What is compile time Exception / checked Exception?
- List few in-built method which throw the checked exception
- What is the difference between checked and un-checked exception?
- What is Error?
- What is Throwable?
- What is the difference between Error and Exception?
- What is custom exception? Or What is user defined exception?
- How to create a custom un-checked exception?
- How to create custom checked exception?
- Collection Framework
- What is a Framework?
- What is a difference between Collection and array?
- What is Collection?
- How to represent the hierarchy of Collection?
- What is the difference between add(Object ref) and add(int index, Object ref) method?
- What is the difference between add(int index, Object ref) and set(int index, Object ref) method?
- List the methods of ArrayList
- List the methods of LinkedList
- What is the difference between ArrayList and LinkedList?
- What is the difference between Iterator and ListIterator?
- What is the difference between size(), length() and length?
- What is the difference between Vector and ArrayList?
- Explain about Enumeration interface
- What is List?
- What is Set?
- What is the difference between List and Set?
- List the methods of HashSet?
- What is the difference between HashSet and LinkedHashSet?
- What is the difference between HashSet, LinkedHashSet and TreeSet?
- What is Comparator?
- What is Comparable?
- What is the difference between Comparator and Comparable?
- What is Queue in java Collection
- What is Priorityqueue?
- What is the difference between peek and poll in queue?
- What is Map?
- How to represent the hierarchy of Map?
- What is Entry?
- What is EntrySet?
- List the method of HashMap
- What is the difference between HashMap and LinkedHashMap?
- What is the difference between HashMap and HashTable?
- What is the difference between HashMap and TreeMap?
- Stream and Lambda
- What is Lambda expression?
- What is functional interface?
- What are the advantages of Lambda expression?
- What is Function?
- What is Predicate?
- What is Consumer?
- What is Supplier?
- What is a Stream API?
- What is the difference between Stream and Collection?
- What is the use of map() method in Stream, explain with example
- What is the use of filter() method in Stream, explain with example
- What is the use of flatMap() method
- What is the difference between map() and flatMap()
- Threads
- What is a Thread?
- What are the different ways to create thread? Explain each way with an example
- Explain the life cycle of Thread?
- What is the use of sleep method?
- What is the use of wait method?
- What is the difference between sleep and wait?
- What does notify and notifyAll method does?
- What is the difference among three wait methods?
- What is volatile?
- Can we use volatile keyword on methods and constructors?
- What is synchronization?
- How to achieve synchronization in java?
- What is thread safe?
- What is parallel execution?
- What is the difference between parallel and serial execution?
×
JDBC
Will be updated
×
Servlets
Will be updated
×
Hibernate
Will be updated
×
SpringCore
Will be updated
×
SpringMVC
Will be updated
×
SpringSecurity
Will be updated
×
SpringBoot
Will be updated
×
LogicalPrograms
- Simple Programs Java fundamentals
- WAP to find sum of two numbers
- WAP to find the average of three integer numbers
- WAP to find the area of a circle
- WAP to find circumference of a circle
- WAP to find the percentage of a student
- WAP to find the sum of four numbers
- WAP to calculate the percentage of the student
- WAP to calculate the discount price
- WAP to calculate the service tax
- WAP to print On-road price of the car, were it has 18.5% of road tax and 12.9% insurance of ex-showroom price of the car
- WAP to swap two numbers using temporary variable
- WAP to swap two numbers without using temporary variable
- WAP to print if the number is odd or even
- WAP find the largest of three numbers
- WAP to find if the given number is divisible by both 4 and 7
- WAP to print the grade of the student, with respect to scored percentage
- WAP to print BMI result of a person for the calculated BMI value
- WAP to print the numbers from 1 to 10
- WAP to print the numbers from 10 to 1
- WAP to print if the number if odd or even from 1 to 10
- WAP to print the numbers from 1 to 200, who are divisible by both 3 and 5
- WAP to print only odd numbers from 1 to 100, which are divisible by 7
- WAP to print if the given number is prime or not
- WAP to print the prime numbers in the given range
- WAP to find the sum of n numbers
- WAP to find the product of n numbers
- WAP to find the factorial of given number
- WAP to find the fibonacci series of given number
- WAP to reverse the given number
- WAP to count number of digits present in the given number