Java programming interview questions for 4 years
1. FizzBuzz Problem Question: Write a Java program that prints the numbers from 1 to 100. But for multiples of three, print "Fizz" instead of the number and for the…
1. FizzBuzz Problem Question: Write a Java program that prints the numbers from 1 to 100. But for multiples of three, print "Fizz" instead of the number and for the…
Core Java Explain the differences between ArrayList and LinkedList. ArrayList uses a dynamic array to store elements, while LinkedList uses a doubly linked list. ArrayList allows fast random access (O(1))…
What is polymorphism, and how is it achieved in Java? Polymorphism is the ability of an object to take on many forms. It is achieved in Java through method overloading…
Multiple inheritances cannot be achieved in java. To overcome this problem the Interface concept is introduced. An interface is a template which has only method declarations and not the method…
Method overloading happens for different classes or within the same class. For method overloading, sub-class method should satisfy the below conditions with the Super-class method (or) methods in the same…
Method overriding happens if the sub-class method satisfies the below conditions with the Super-class method: Method name should be the same The argument should be the same Return type should…
Polymorphism means many forms. A single object can refer to the super-class or sub-class depending on the reference type which is called polymorphism. Example: Public class Manipulation(){ //Super class public…
Purpose of Encapsulation: Protects the code from others. Code maintainability. Example: We are declaring ‘a’ as an integer variable and it should not be negative. public class Addition(){int a =…
Inheritance means one class can extend to another class. So that the codes can be reused from one class to another class. The existing class is known as the Super class…
OOPs concepts include: Inheritance Encapsulation Polymorphism Abstraction Interface