Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
8.9k views
in Computer by (49.9k points)
closed by

Define a class Repeat which allows the user to add elements from one end (rear) and remove elements from the other end (front) only. 

The following details of the class Repeat are given below: Class name: 

Repeat Data Members/instance variables: 

st[]: an array to hold a maximum of 100 integer elements 

cap: stores the capacity of the array 

f: to point the index of the front 

r: to point the index of the rear 

Member functions: 

Repeat (int m): constructor to initialize the data members cap = m, f = 0, r = 0 and to create the integer array

void pushvalue (int v): to add integer from the rear index if possible else display the message (“OVERFLOW”) 

int popvalue (): to remove and return element from the front. 

If array is empty then return -9999 

void disp (): Displays the elements present in the list 

(a) Specify the class Repeat giving details of the constructor (int), member function void pushvalue (int). int popvalue () and void disp (). 

The main ( ) function need not be written.

(b) What is the common name of the entity described above? 

(c) On what principle does this entity work?

1 Answer

+1 vote
by (49.0k points)
selected by
 
Best answer

import java.io.*; 

Class Repeat { intan []; 

int cap, f, r; 

public Repeat (int m) 

cap = m; 

f=0; r=0; 

an [ ] = new int[100]; 

public void pushvalue (int v) 

{ if (r = = cap) 

Systemout.println ("OVERFLOW"); 

else if (f = = 0) 

{

 f = 1; 

else 

an [r++] = v; 

public int popvalue ( ) 

if (f == 0) 

System.out.println (-9999); 

elseif(f=r) 

{

f=0; r = 0; 

else 

{ return (an [f++]); 

public void display ( ) 

for (i = f; i< = r; i ++) 

System.outprintln (an [ i ]; 

}

(b) Queue 

(c) It works on first in first out Principle(FIFO).

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...