Interview challenge based on covered topics



OOP Concepts

  1. Create a class Car: Define attributes like make, model, and year, and include a method to display the car's details. Instantiate objects and display information for different cars.

  2. Design an Employee Management System: Create a base class Employee with properties like name, ID, and salary. Inherit from it to create a Manager class with additional properties like department.

  3. Library System: Create classes Book and Member. The Book class should have attributes like title and author, and the Member class should manage borrowing and returning books.

  4. Shape Hierarchy: Create a base class Shape with a method calculateArea(). Derive classes Circle, Rectangle, and Triangle from Shape, and implement the area calculation in each derived class.

  5. Student Class: Design a Student class with attributes like name, age, and marks. Create a derived class GraduateStudent that adds extra fields like thesis and calculate the final grade based on marks.

  6. Account System: Implement a base class Account with basic methods for deposit and withdrawal. Create a derived class SavingsAccount that implements interest calculation.

  7. Inheritance of Vehicles: Create a class Vehicle and derived classes Car, Truck, and Motorcycle. Each derived class should implement a method that returns its fuel efficiency.

  8. Zoo Management System: Create an abstract class Animal with methods eat() and sleep(). Derive classes Lion, Elephant, and Giraffe that override these methods.

  9. Shape Drawing System: Create an abstract class Shape with a method draw(). Inherit it in classes Circle, Rectangle, and Triangle. Implement the draw method to display the shape in a 2D format.

  10. Employee Salary Calculator: Create a class Employee with name, id, and salary. Then, create a Manager class that inherits from Employee and adds a method to calculate bonus.


If-Else Concepts

  1. Odd or Even: Write a program that takes an integer as input and checks if it is odd or even using if-else statements.

  2. Grade Calculator: Write a program that takes a student’s marks as input and prints the grade (A, B, C, D, F) based on the range of marks using if-else.

  3. Leap Year Checker: Write a program to check if a given year is a leap year or not using if-else conditions.

  4. Simple ATM: Simulate an ATM system where the user is prompted to enter their pin. Use if-else statements to check if the pin matches the stored value. If it matches, allow the user to withdraw money, else deny access.

  5. Age Category: Write a program that checks if a person is a child, teenager, or adult based on their age using nested if-else statements.


Basic Java String

  1. Palindrome Checker: Write a program that takes a string as input and checks if it’s a palindrome or not.

  2. String Reverse: Write a program to reverse a string entered by the user without using built-in methods like reverse().

  3. Count Vowels and Consonants: Write a program that counts the number of vowels and consonants in a given string.

  4. Character Frequency: Write a program that takes a string and a character as input and counts how many times the character appears in the string.

  5. String Concatenation: Write a program that takes two strings as input and prints the concatenated string without using the + operator.


Array-Based Challenges

  1. Find Maximum in Array: Write a program that finds the largest number in an array using loops.

  2. Array Sum: Write a program that takes an array of integers as input and returns the sum of all the elements.

  3. Reverse an Array: Write a program to reverse the elements of an array without using built-in methods.

  4. Find Missing Number in Array: Given an array of integers from 1 to N, write a program to find the missing number using an array.

  5. Array Rotation: Write a program that rotates an array to the right by k positions.

  6. Duplicate Elements in Array: Write a program that finds and displays all the duplicate elements in an array.

  7. Find Second Largest in Array: Write a program to find the second-largest number in an unsorted array.

  8. Merge Two Arrays: Write a program to merge two arrays of integers into one sorted array.

  9. Check for Array Symmetry: Write a program that checks whether an array is symmetric (i.e., it reads the same forward and backward).

  10. Array Intersection: Write a program that finds the intersection of two arrays (i.e., elements that are common to both arrays).



Comments

Popular posts from this blog

10 automation test cases for https://www.saucedemo.com/ (Sauce Demo)

Java Roadmap for SDET Superstars!

Mastering XPath in Selenium 4 ๐Ÿš€ – Supported Functions & Axes Explained