OOP PROBLEMS ?
1.

ANSWER...

2.

ANSWER...

3.

ANSWER...

4.

ANSWER...

5. Rack is a kind of data structure which can store at the most 20 books. The rack restriction is that a book can be kept into the rack or removed only at one end i.e. on the top.
The class Rack has the following details:
Class name : Rack
Data members:
book[] : array of string of maximum 50 locations to store books.
name : string variable to store name of book to be kept in the array book[].
limit : integer as maximum capacity of the array.
top : integer to indicate topmost book into the Rack.
Member functions :
Rack() : a constructor to store blank in the array book[].
Rack(int nx) : a constructor to assign nx to limit and -1 to top.
void dispList() : to display list of books in the rack.
boolean isEmpty() : returns true, if rack is empty otherwise returns false.
void putTheBook() : input name of the book into variable name and adds it on the top into
the array book[] if rack is empty otherwise prints a message “Rack is
overflow”.
void removeBook() : removes a book from the top of the rack, if rack is not empty and print
the book name, otherwise outputs a message “Rack is underflow”.
Specify the class Rack giving details of constructor Rack(int nx) and functions boolean isEmpty(), void putTheBook(), void removeBook() only. Assume that other constructors and functions are already written for you. You do not need to write the main function.

ANSWER...

6. 1. Write a program to input a number and check whether it is a Circular prime or not.{A number is said to be circular prime when its all digits are rotated in all rotations it spells prime.}
2. Write a program to read a number and find out if the number is a Lucas number or not.{A number is said to be Lucas number when the sum of the number and its reverse is a prime. If not, repeat the process with the resultant number until a prime number is obtained, at least 50 times.}
3. Write a program to read a number and check whether it is a Bouncing number or not.{A number is said to be bouncing number when its digits are in order either ascending or descending.}
4. Write a program to read a number and print its prime factors.
5. Write a program to read a number(bouncing number in ascending order) and insert a particular input digit(x) in the number.
6. Write a program to read a number and remove particular digit(x) from the number.
7. Write a program to read n number of values and print the missing numbers between the minimum and the maximum value.
8. Write a program to read n number of values in an array and find out value which is equal to product of other elements of array except the number itself.
9. Write a program to read n number of values and rearrange elements in order of odd elements following even elements.
10. Write a program to read n number of values in an array and enter a value k, if k is positive rotate right else if k is negative rotate left.
11. Write a program to read n number of values and rearrange negative elements in descending order using insertion sort and positive elements in ascending order using selection sort.
12. Write a program to read two matrices A&B of different sizes and find its matrix product AxB.
13. Write a program to read a matrix and print its upper diagonal, lower diagonal, left diagonal, right diagonal, elements separately in matrix form.
14. Write a program to read month and year number and print its monthly calendar.
15. Write a program to read an ASCII String and convert it into letter String.
16. Write a program to read a String and number of line(s) as input and print String letters in wave spreading n lines by avoiding blank spaces.
17. Write a program to read a word and print it’s all possible combinations by changing letter position in the word.
18. Write a program to read a String and find out the Sentence String is A Palindrome or not.
19. Write a program to read and generate a nxn square matrix and fill n natural numbers in such a way the sum of all rows and columns are equal.
20. Write a program to read a String and remove all duplicates substrings whether it is a word or part of the word.
21. Write a program to read a Binary Matrix of size nxm and find the matrix is a map or not.{A matrix is said to be a Map when 1’s are present and leads from starting index(0,0) to ending(n-1,m-1). Lead means 1 are present in adjacent cells in a row or column.}

ANSWER...

7. There is a class called Merge is declared with following details:
Class name : Merge
Data members :
int arr[] : an array of integers.
int size : number of integers in array.
Member functions :
Merge(int n) : constructor to create a list.
void inputList() : to input the numbers in the list.
void displayList() : to print list of integers.
void sortList() : to arrange the list in ascending order using Insertion sort technique.
Merge mergeList(Merge y): to merge the list arr with the current ascending list object and return a
third ascending list which is also sorted in ascending order.
Important : While generating the final list both the original ascending list must be scanned only once. Elements common to the two lists should appear only once in the third ascending list.

ANSWER...

8.

ANSWER...

9. Design a class date which helps to get date operations. The details of the members of the class are given below :
Class name : date

Data members /instance variables:
dd : stores day
mn : stores a month
yr : stores a year

Member functions :
date( ) : default constructor
date(date x) : copy constructor
void readDate( ) : to accept the Date from user
int getDays() : it converts the date into days.
static int compareDates(date x, date y):
This is to compare two dates and returns the result as
0 if x=y
+ve if x>y then returns the number of days ahead
-ve if x<y then returns the number of days lagging

void display( ) : displays date.

Specify the class date giving details of the constructor, void readDate( ), int getDays(), int compareDates(), and void display( ). Define the main( ) function to read two dates using the class date and find the differences in days.

ANSWER...

10.

ANSWER...

11.

ANSWER...

12.

ANSWER...

13. A Vampire number is a composite natural number with an even number of digits that can be factored into two natural numbers each with half as many digits as the original number and not both with trailing zeros, where the two factors contain precisely all the digits of the original number, in any order of counting multiplicity.
Example : 1260 = 21 x 60 ( where 21 and 60 contain precisely all the digits of the number). Thus, 1260 is a Vampire number.


Design a class Vampire which helps to find the number is Vampire number or not. The details of the members of the class are given below :

Class name : vampire
Data members /instance variables:
n : number
Member functions :
vampire( ) : default constructor
void readNumber( ) : to accept the number
boolean isVampire() : it checks the number n is vampire or not and returns true when it is vampire otherwise false.
void display( ) : displays the number along with the suitable message.

Specify the class Vampire giving details of the constructor, void readNumber( ), boolean isVampire() and void display( ). Define the main( ) function to create vampire object to print all vampire numbers between a and b where a<b.

ANSWER...

14. Design a class Sort which enables words of a sentence in alphabetical order. The details of the members of the class are given below :
Class name : Sort
Data members /instance variables:
str : stores a sentence
Member functions :
Sort( ) : default constructor
void readSentence( ) : to accept the sentence
String getWord(int i) : it returns the ith word of a sentence in str.
String arrange (String wrd ) : to arrange the parameter word letters in
alphabetical order using any standard sorting
technique.
void display( ) : displays each word of a sentence and its sorted word.

Specify the class Sort giving details of the constructor, void readSentence( ), String getWord(int), String arrange(wrd ), and void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task.

ANSWER...

15. Design a class Palindrome which enables to check the sentence string is palindrome or not. The details of the members of the class are given below :
Class name : Palindrome
Data members /instance variables:
str : stores the sentence string
Member functions :
Palindrome( ) : default constructor
void readSentence( ) : to accept the Sentence String
boolean isPalindrome(String wrd) : it returns true if the word is palindrome using recursive method.

void display( ) : displays the message ‘Sentence is Palindrome’ when all words of a sentence is palindrome.

Specify the class Palindrome giving details of the constructor, void readSentence( ), boolean isPalindrome(String), and void display( ). Define the main( ) function to create an object and call the functions accordingly to enable the task.

ANSWER...

16.

ANSWER...

17.

ANSWER...

18.

ANSWER...

19.

ANSWER...

20. A class OctaHexa has been defined to convert an Octal number into its equivalent Hexa-Decimal number. Some of the members of the class are given below:
Class name : OctaHexa
Data members :
N : integer octal to be converted to its Hexa-decimal form.
Member functions :
OctaHexa() : constructor to assign initial value to the data members.
void getOctal() : to accept Octal integer N.
int o2d (int) : to find the decimal equivalent of the octal number
using recursive method.
String d2h(int) : to find the hexa-decimal value of the decimal number
using recursive method.
Specify the class OctaHexa by giving the details of int o2d(int), and String d2h(int) functions. write a main program to convert an input octal number into hexa-decimal.

ANSWER...

21. Design a class Time which helps to find the time operations. The details of the members of the class are given below :
Class name : Time
Data members /instance variables:
hr : stores hour
mn : stores a minute
sec : stores a second
noon : stores the noon values ‘AM/PM’
Member functions :
Time( ) : default constructor
void readTime( ) : to accept the Time
int getSeconds() : it converts the whole time into seconds.
static Time addSeconds (Time x, int sec) : This is to add seconds(sec) with the parameter time object(x) and returns the resultant time.
void display( ) : displays time.

Specify the class Time giving details of the constructor, void readTime( ), int getSeconds(), Time addSeconds(), and void display( ). Define the main( ) function to realize the above operations.

ANSWER...

22.

ANSWER...

23.

ANSWER...

24. A set is a collection in which there is no duplication of elements. S= [1,6,9,24} is a set of 4 integer elements. An array of integers may be used to represent a set.
Class : Set
Data Members
a[] : an array to hold integers
n : an integer to store the number of elements in the array a
Member functions
Set(int nn) : constructor to initialize n and the array a
void readelements() : reads the elements of the set.
void displayelements() : displays the elements of the set.
int search(int x) : returns 1 if x is present in the array a else 0
set intersection(set d) : returns the intersection of set object d and the
current object(i.e the common elements of both)
set union(set d) : returns the union of set object d and the current
object(i.e. the elements present of both without
duplicates)
Design a class Set by giving the details of all functions. Define main function to read 3 sets A, B, and C using the class Set and print the union of A,B, and C, intersection of A, B & C.

ANSWER...

25.

ANSWER...

26. The time is calculated as
Let first time = 1 day 7 hours 45 minutes 30 seconds
Let second time = 2 day 19 hours 30 minutes 40 seconds
The sum of time will be
4 day 3 hours 16 minutes 10 seconds
A class time is designed as
Class name Time
Data Members
Day, hr, mn,sec : integer variables to store time values
Member functions
Time() : constructor
voidinputTime() : to input values of day, hr, mn and sec.
voidprintTime() : to print day, hr, mn and sec with proper messages
Time SumofTime(Time t1, Time t2) to find the sum of times from parameter objects t1 and
t2 using above method of addition and return sum of Time.
Write a program to read N number of times based on above class and find the total of N different times.

ANSWER...

27. A set is a collection in which there is no duplication of elements. S= [1,6,9,24} is a set of 4 integer elements. An array of integers may be used to represent a set.
Class : Set
Data Members
a[] : an array to hold integers
n : an integer to store the number of elements in the array a
Member functions
Set(int nn) : constructor to initialize n and the array a
void readelements() : reads the elements of the set.
void displayelements() : displays the elements of the set.
int search(int x) : returns 1 if x is present in the array a else 0
set intersection(set d) : returns the intersection of set object d and the
current object(i.e the common elements of both)
set union(set d) : returns the union of set object d and the current
object(i.e. the elements present of both without
duplicates)
Design a class Set by giving the details of all functions. Define main function to read 3 sets A, B, and C using the class Set and print the union of A,B, and C, intersection of A, B & C.

ANSWER...

28.

ANSWER...

Hungry Minds


HUNGRY MINDS
REG.NO. 09AKEPV9632M2Z9
Regd. Office : 120, Khirighat, Basti - 272002,
Uttar Pradesh , India.

Branch Office : No 91, Vallalar Nagar, V.M. Chatiram,
Tirunelveli - 627011, India

Our Services

School Software

Payment Gateway

Church Management Software

Mobile Apps

Ecommerce Site Development

Robotics Classes



hungryminds.basti@gmail.com

vasantharaj1972@gmail.com

- 2024 Copyright is Reserved. Hungry Minds 7780, India - 7985872766.