This blog explains about OPTISOL INTERVIEW QUESTIONS FOR FRESHERS WITH ANSWERS and is given below :


1. Write a java program to ” Reverse a string using recursion” 

To understand these programs you should have the knowledge of following core java concepts:
1) substring() in java
2) charAt() method


// Java program to reverse a string using recursion


class StringReverse


    /* Function to print reverse of the passed string */

    void reverse(String str)


        if ((str==null)||(str.length() <= 1))









    /* Driver program to test above function */

    public static void main(String[] args) 


        String str = “Payilagam”;

        StringReverse obj = new StringReverse();






” magaliyaP “


2. Explain briefly about Collection program(list,set,map)

                                                L 6

List in Java provides ordered and indexed collection which may contain duplicates. 

The Set interface provides an un ordered collection of unique objects, i.e. Set doesn’t allow duplicates, while Map provides a data structure based on key-value pair and hashing. 

All three List, Set, and Map are interfaces in Java and there are many concrete implementations of them are available in Collection API.

L 1

 ArrayList and LinkedList are two most popular used List implementation while LinkedHashSet, TreeSet, and HashSet are frequently used Set implementation. 

3. Explain briefly about function overloading and function overriding

Overriding and Overloading are two very important concepts in Java.

They are confusing for Java novice programmers. This post illustrates their differences by using two simple examples.

  1. Definitions


 It occurs when two or more methods in one class have the same method name but different parameters.


It means having two methods with the same method name and parameters (i.e., method signature). One of the methods is in the parent class and the other is in the child class. Overriding allows a child class to provide a specific implementation of a method that is already provided its parent class.

  1. Overriding vs. Overloading

Here are some important facts about Overriding and Overloading:

1). The real object type in the run-time, not the reference variable’s type, determines which overridden method is used at runtime. In contrast, reference type determines which overloaded method will be used at compile time.
2). Polymorphism applies to overriding, not to overloading.
3). Overriding is a run-time concept while overloading is a compile-time concept.

  1. An Example of Overriding

Here is an example of overriding. After reading the code, guess the output.

class Dog{

    public void bark(){

        System.out.println(“woof “);



class Hound extends Dog{

    public void sniff(){

        System.out.println(“sniff “);



    public void bark(){





public class OverridingTest{

    public static void main(String [] args){

        Dog dog = new Hound();






An Example of Overloading

class Dog{

    public void bark(){

        System.out.println(“woof “);



    //overloading method

    public void bark(int num){

      for(int i=0; i<num; i++)

           System.out.println(“woof “);



In this overloading example, the two bark method can be invoked by using different parameters. Compiler know they are different because they have different method signature .


4. Explain briefly about  sql query using inner joint 

Introduction to SQL Server INNER JOIN

The inner join is one of the most commonly used joins in SQL Server. The inner join clause allows you to query data from two or more related tables.

A SQL Join statement is used to combine data or rows from two or more tables based on a common field between them. Different types of Joins are:


Consider the two tables below:


L 2


L 4

The simplest Join is INNER JOIN.

  1. INNER JOIN:The INNER JOIN keyword selects all rows from both the tables as long as the condition satisfies. This keyword will create the result-set by combining all rows from both the tables where the condition satisfies i.e value of the common field will be same.
  2. SELECT table1.column1,table1.column2,table2.column1,….
  3. FROM table1
  4. INNER JOIN table2
  5. ON table1.matching_column = table2.matching_column;
  6. table1: First table.
  7. table2: Second table
  8. matching_column: Column common to both the tables.

Note: We can also write JOIN instead of INNER JOIN. JOIN is same as INNER JOIN.

Example Queries(INNER JOIN)

  • This query will show the names and age of students enrolled in different courses.
  • SELECT StudentCourse.COURSE_ID, Student.NAME, Student.AGE FROM Student
  • INNER JOIN StudentCourse
  • ON Student.ROLL_NO = StudentCourse.ROLL_NO;


L 3


5.Find a duplicate characters in a string

// Java program to find the first

// repeated character in a string

import java.util.*;


class Main


    // This function prints the first repeated

    // character in str[]

    static char firstRepeating(char str[])


        // Creates an empty hashset

        HashSet<Character> h = new HashSet<>();


        // Traverse the input array from left to right

        for (int i=0; i<=str.length-1; i++)


            char c = str[i];


            // If element is already in hash set, update x

            // and then break

            if (h.contains(c))

                return c;


            else // Else add element to hash set




        return ‘\0’;



    // Driver method to test above method

    public static void main (String[] args)


        String str = “geeksforgeeks”;

        char[] arr = str.toCharArray();