Skip to content

Category Archives: Java

Hope you liked my previous post “Top 25 Interview Questions”. Here comes the next 10. 1) Design discussion on elevator. Hint: Ask questions related to… Read More
When we assign an integer value to an Integer object, the value is autoboxed into an Integer object. For example the statement “Integer x =… Read More
final keyword is used in different contexts. First of all, final is a non-access modifier applicable only to a variable, a method or a class.… Read More
Following features of C++ are not there in Java. No pointers No sizeof operator No scope resolution operator Local variables in functions cannot be static… Read More
Inner class means one class which is a member of another class. There are basically four types of inner classes in java. 1) Nested Inner… Read More
Given an array of integers. Write a Java Program to find the sum of the elements of the array. Examples: Input : arr[] = {1,… Read More
Predict the output of following Java program. class Test {     public static void main (String[] args)      {         int arr1[] = {1, 2, 3};         int arr2[]… Read More
Let us first consider the following Java program as a simple example of Overriding or Runtime Polymorphism. Java class Base {   public void fun() {… Read More
Given a set of characters and a positive integer k, print all possible strings of length k that can be formed from the given set.… Read More
Let us first define Overloading and Overriding.Overriding: Overriding is a feature of OOP languages like Java that is related to run-time polymorphism. A subclass (or… Read More
Can a class be static in Java? The answer is Yes, some classes can be made static in Java. Java supports Static Instance Variables, Static… Read More
Given a dictionary of words and an input string, find the longest prefix of the string which is also a word in dictionary. Examples: Let… Read More
Predict output of the following Java program. // filename: Test2.java      // main() function of this class uses Test1 which is declared later in  //… Read More
In Java, there are two types of exceptions: 1) Checked: are the exceptions that are checked at compile time. If some code within a method… Read More
In C/C++ there is only one right shift operator ‘>>’ which should be used only for positive integers or unsigned integers. Use of right shift… Read More