0% found this document useful (0 votes)
3 views2 pages

Top 10 Java Coding Interview Questions

Uploaded by

ponnaiyaguhan33
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Top 10 Java Coding Interview Questions

Uploaded by

ponnaiyaguhan33
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Top 10 Exam-Oriented Java Coding Questions

Arrays

1. Second Maximum Number

Given an array, find the second largest unique number. If it doesnt exist, return -1.

2. Count Frequency of Each Element

Given an array, print how many times each element occurs.

3. Find Pairs with Given Sum

Return all pairs of elements whose sum equals a target value.

Strings

4. Find the First Non-Repeating Character

Given a string, return the first character that does not repeat anywhere in the string.

5. Check If Two Strings Are Rotations of Each Other

Given two strings, check if one is a rotation of the other.

6. Compress a String

Example: Input: "aaabbcc" Output: "a3b2c2".

Abstraction (OOP Concept)

7. Design a Class Hierarchy for Employees

Create an abstract class `Employee` with method `calculateSalary()`, and two classes `Intern` and

`FullTimeEmployee` that inherit and implement this method.

Polymorphism

8. Shape Area Calculator Using Polymorphism

Use method overriding to calculate area for `Circle`, `Rectangle`, and `Triangle` using a base class

`Shape`.

9. Bank Interest Calculation

Create a superclass `Bank` and subclasses `SBI`, `HDFC`, `ICICI` that override `getInterestRate()`

method. Demonstrate polymorphism.


Mixed (String + Array + OOP Logic)

10. Group Strings by Their Length and Print Alphabetically Within Each Group

Given an array of strings, group them by their length and print each group sorted alphabetically.

You might also like