Git Product home page Git Product logo

oop-lab's Introduction

🎯 Priority questions

  1. 1.1) Program to remove all repeated elements from an array
    1.2) Write a Java program to find the common elements between two arrays of integers.

2.1) Java Program to Count Number of Duplicate Words in String
2.2) How to Check if the String Contains 'e' in umbrella
3.1)Java Program to Reverse a String. 
3.2) Write a Java program to check that String is palindrome or not.
  1. A Company manufactures Vehicles, which could be a Helicopter, a Car, or a Train depending on the customer’s demand. Each Vehicle instance has a method called move, which prints on the console the nature of movement of the vehicle. For example, the Helicopter Flies in Air, the Car Drives on Road and the Train Runs on Track. Write a program that accepts input from the user on the kind of vehicle the user wants to order, and the system should print out nature of movement. Implement all Java coding best practices to implement this program.

  2. We have to calculate the percentage of marks obtained in three subjects (each out of 100) by student A and in four subjects (each out of 100) by student B. Create an abstract class 'Marks' with an abstract method 'getPercentage'. It is inherited by two other classes 'A' and 'B' each having a method with the same name which returns the percentage of the students. The constructor of student A takes the marks in three subjects as its parameters and the marks in four subjects as its parameters for student B. Create an object for eac of the two classes and print the percentage of marks for both the students.

  3. Write the following code in your editor below: A class named Arithmetic with a method named add that takes 2 integers as parameters and returns an integer denoting their sum. A class named Adder that inherits from a superclass named Arithmetic. The main method in the Tester class should print the following: SAMPLE O/P:My superclass is: Arithmetic 42 13 20

  4. You are required to compute the power of a number by implementing a calculator. Create a class My Calculator which consists of a single method long power (int, int). This method takes two integers n and p, as parameters and finds (n)p. If either or is negative, then the method must throw an exception which says " n or p should not be negative”. Also, if both and are zero, then the method must throw an exception which says "n or p should not be negative”.

  5. You are given a phone book that consists of people's names and their phone number. After that you will be given some person's name as query. For each query, print the phone number of that person. Use HashMap to implement it.The first line will have an integer denoting the number of entries in the phone book. Each entry consists of two lines: a name and the corresponding phone number. After these, there will be some queries. Each query will contain a person's name. Read the queries until end-of-file. Constraints: A person's name consists of only lower-case English letters and it may be in the format 'first-name last-name' or in the format 'first-name'. Each phone number has exactly 8 digits without any leading zeros.For each case, print "Not found" if the person has no entry in the phone book. Otherwise, print the person's name and phone number.

image

image

11.1) Write a Java program that takes a number as input and prints its multiplication table up to 10. Test Data:
    Input a number: 8
    Expected Output :
    8 x 1 = 8
    8 x 2 = 16
    8 x 3 = 24
    ...
    8 x 10 = 80 
	
11.2) Write a java program to check that given number is prime or not.
  1. Write a Java program to display the pattern like a diamond. Input number of rows (half of the diamond) :7 Expected Output :

image

13.1) Write Java Program to find the transpose of a given matrix . 
13.2) Write Java Program to find the number of the words in the given text file.

image

  1. Write a Java Program to iterate ArrayList using for-loop, iterator, and advance for-loop. Insert 3 Array List.Input 20 30 40 Output:

    iterator Loop: 20 30 40

    Advanced For Loop: 20 30 40

    For Loop: 20 30 40

  2. Write a Java Program to count the number of words in a string using HashMap.Output: Input :Enter String: "This this is is done by Saket Saket"; {Saket=2, by=1, this=1, This=1, is=2, done=1}

  3. Write a program to read 10 string from console and then print the sorted strings on console (Use String Class).2) combine two string 3)reverse first string nd dispaly it .

  4. Write a program to implement following inheritance. Accept data for 5 persons and display the name of employee having salary greater than 5000.

    Class Name: Person Member variables: Name, age

    Class Name: Employee Member variables: Designation, salary

  5. Implementing “Multiple Inheritance”. Create a two interfaces Account containing methods set() and display() And interface Person containing methods store() and disp(). Derive a class Customer from Person and Account. Accept the name, account number, balance and display all the information related to account along with the interest.

  6. "Write a program, to implement the following hierarchy. Displays information of each class the rectangle represents the classes. The classes Movie and MusicVideo inherits all the members of the class VideoTape. "

image

  1. Write a Java program to create a class called "Student" with a name, grade, and courses attributes, and methods to add and remove courses.

  2. Write a Java program to create a class known as Person with methods called getFirstName() and getLastName(). Create a subclass called Employee that adds a new method named getEmployeeId() and overrides the getLastName() method to include the employee's job title.

  3. Write a Java program to find the length of the longest consecutive elements sequence from an unsorted array of integers. Sample array: [49, 1, 3, 200, 2, 4, 70, 5] The longest consecutive elements sequence is [1, 2, 3, 4, 5], therefore the program will return its length 5.

  4. Create a class Student with attributes roll no, name, age and course. Initialize values through parameterized constructor. If age of student is not in between 15 and 21 then generate user-defined exception "AgeNotWithinRangeException". If name contains numbers or special symbols raise exception "NameNotValidException". Define the two exception classes.

image

🚀 Extra questions

  1. Write a program for calculator –Addition, subtraction, multiplication and division.
  2. WAP to swap two numbers using third variable.
  3. WAP to swap two numbers without using third variable.
  4. Check that given number is even or not.
  5. Calculate the factorial of a given number.
  6. Check that given number is Prime or not.
  7. Display first 10 prime numbers.
  8. Reverse the given number.
  9. Check that given number is palindrome or not.
  10. Check that given number is Armstrong or not.Eg-153=13+53+33=1+225+27=153
  11. WAP for constructor types.
  12. WAP for method types
  13. WAP to display information of 3 employees, take the data from user.
  14. WAP to display the use of access specifiers.
  15. Java Program to Find Out the Number of Objects Created of a Class.
  16. Java Program to Check Whether a Character is a Vowel, Consonant or Digit
  17. Java Program to Check Whether a Given Alphabets are Uppercase or Lowercase or Digits
  18. Display the sum of digits of a number.
  19. Calculate the power of a number without power function and with power function.
  20. Java program to check leap year.
  21. Write a Java program to create and display unique three-digit number using 1, 2, 3, 4. Also count how many three-digit numbers are there. 123
  22. Write a Java program to print the ASCII value of a given character.
  23. Finding square root of a number. Program to print a given number's square root without employing the math.sqrt() function.
  24. WAP to accept the array elements from user and display the elements.
  25. Write a Java Program to find the highest number and lowest number in an array.
  26. Program to add any two given matrices and print the result.
  27. Program to multiply any two given matrices and print the result.
  28. Transposing Matrix. Program to print the transpose of a given matrix. A transpose of a matrix has all its rows and columns interchanged.
  29. Write a Java Program to find the second-highest number in an array.
  30. Calculate and return the sum of all the even numbers present in the numbers array passed to the method calculateSumOfEvenNumbers. Implement the logic inside calculateSumOfE venNumbers() method.Test the functionalities using the main() method of the Tester class.
  31. Program to identify and remove all repeated elements from an array.
  32. Write a Java program that demonstrate the the use of method overloading, method overriding and method hiding.
  33. Write a Java program to find the common elements between two arrays of string (Hint:equals())
  34. Write a Java program to find the common elements between two arrays of integers
  35. Check the equality of two arrays.
  36. Write a Java program to create an array of its anti-diagonals from a given square matrix.
  37. Write a Java program to segregate all 0s on left side and all 1s on right side of a given array of 0s and 1s.
  38. Java Program to Count Number of Duplicate Words in String
  39. Java Program to Reverse a String.
  40. How to Check if the String Contains e in umbrella
  41. Check word orange in “This is Orange juice”.
  42. Remove all whitespace. VIT Pune-VITPune
  43. Java Program to Check if Input String is Palindrome
  44. Write a Java program to count the number of words in a string?
  45. Write a Java program to check whether two strings are anagram or not?
  46. Write a java program that accept your full name as input and display initial of first and middle name and complete last name . Varsha Rahul Dange-V. R. Dange
  47. WAP to demonstrate the use of throws and throw in exception handling.
  48.  Create a class Student with attributes roll no, name, age and course. Initialize values through parameterized constructor. If age of student is not in between 15 and 21 then generate user-defined exception "AgeNotWithinRangeException". If name contains numbers or special symbols raise exception "NameNotValidException". Define the two exception classes.
  49. Write a Java program which creates only one object. If user attempts to create second object, he should not be able to create it. Display appropriate meassage (Using Exception Handling).
  50. A Company manufactures Vehicles, which could be a Helicopter, a Car, or a Train depending on the customer’s demand. Each Vehicle instance has a method called move, which prints on the console the nature of movement of the vehicle. For example,the Helicopter Flies in Air, the Car Drives on Road and the Train Runs on Track. Write a program that accepts input from the user on the kind of vehicle the user wants to order, and the system should print out nature of movement. Implement all Java coding best practices to implement this program.
  51. Create an abstract class 'Bank' with an abstract method 'getBalance'. $100, $150 and $200 are deposited in banks A, B and C respectively. 'BankA', 'BankB' and 'BankC' are subclasses of class 'Bank', each having a method named 'getBalance'. Call this method by creating an object of each of the three classes.
  52. We have to calculate the percentage of marks obtained in three subjects (each out of 100) by student A and in four subjects (each out of 100) by student B. Create an abstract class 'Marks' with an abstract method 'getPercentage'. It is inherited by two other classes 'A' and 'B' each having a method with the same name which returns the percentage of the students. The constructor of student A takes the marks in three subjects as its parameters and the marks in four subjects as its parameters for student B. Create an object for eac of the two classes and print the percentage of marks for both the students.
  53. An abstract class has a construtor which prints "This is constructor of abstract class", an abstract method named 'a_method' and a non-abstract method which prints "This is a normal method of abstract class". A class 'SubClass' inherits the abstract class and has a method named 'a_method' which prints "This is abstract method". Now create an object of 'SubClass' and call the abstract method and the non-abstract method. (Analyse the result)

oop-lab's People

Contributors

bhavyabh289 avatar heapbytes avatar soham1803 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.