Explanation of Solution
Define an abstract data type that represents list of names using Java class syntax.
Abstract data type is used to store the data in a structure and provides different method to manipulate the data stored.
//The interface is created using the following method
interface Names
{
// Declare a method pushback()
public void pushback(String str);
// Declare a method popback()
public String popback();
// Declare a method getname()
public String getname (int x);
}
// Interface is implemented by defining the class namelist
class namelist implements Names
{
// Declare an array
private String[] name;
// Declare an integer size
private int size;
// Definition of constructor
public namelist()
{
// Size is initialized
size=0
}
// Define a method pushback()
public void pushback(String str)
{
// Assign string
name[size]=str;
// Increment the size
size++;
}
// Define a method popback()
public String popback()
{
// Decrement the size and return the name
return name[--size];
}
// Define a method getname()
public String getname(int x)
{
// Check the condition
if(x<size)
// Return name
return name[x];
// Otherwise
else
// Return null
return null;
}
// Define a method display()
public void display()
{
// For loop to iterate the loop
for(int i=0;i<size;i++)
{
// Print the names
System...
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
EBK COMPUTER SCIENCE: AN OVERVIEW
- What exactly is a data structure? What is the definition of abstract data type? Explain your solution with the help of an example.arrow_forwardWhat exactly is meant by the term "data structure"? What exactly is meant when one refers to something as having the status of an abstract data type? Would you be able to expound on your response by providing an example?arrow_forwardExplain the concept of data binding expressions and their usage in server-side technologies like ASP.NET or JavaServer Faces (JSF).arrow_forward
- What is a data structure, exactly? What exactly is an abstract data type? Use an example to demonstrate your answer.arrow_forwardA strongly-typed data type implementation supports strongly-typed data, whereas a loosely-typed data type implementation supports loosely-typed data.arrow_forwardWhat Ada construct provides support for abstract data types?arrow_forward
- What exactly is meant by the term "data structure"? What exactiy is meant when one refers to something as having the status of an abstract data type? Would you be able to expound on your response by providing an example?arrow_forwardStructure data-entry fields in accordance with the following rules: Can you conceive of any situations in which breaking these rules would be appropriate?arrow_forwardData abstraction and control abstraction both have their drawbacks.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education