
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Consider the following Java classes. Assuming that all of these classes are in the same directory. What will be the output when TestClassC is compiled and run.

Transcribed Image Text:9
10
11
12
13
14
15
16
17 }
123
1 import java.util.ArrayList;
2 public class ClassA {
3 protected ArrayList<String> strings;
public ClassA() {
4
5
strings = new ArrayList<String>
6 ( ); }
7
8
2
public void add(String s) {
strings.add(s);
3
4
5
6
7
8 }
}
public String toString() {
String temp = "";
for (Strings
}
1 public class ClassB extends ClassA {
public ClassB() {
super();
strings) {
temp + s + "\n";
}
return temp;
}
public void add(String s) {
strings.add(s. to LowerCase());
![1 public class ClassC extends ClassB {
2 public ClassC() {
4
5
6
7
8
9
10
11
12
13
14
15}
9
10}
}
super();
}
public String toString() {
String temp = "";
for (int i = 0; i < strings.size(); i++) {
temp += "#" + strings.get(i) + "#";
if (i < strings.size() - 1) {
temp + "\n";
}
1 class TestClassC {
2
3
}
}
return temp;
public static void main(String[] args) {
ClassC myList = new ClassC();
myList.add("STOP");
myList.add("GO");
myList.add("TURN" );
O
System.out.print(myList);
System.out.println("all done");](https://content.bartleby.com/qna-images/question/d70ce811-7ef1-402c-bf4e-4d7de267bc9d/ad479ced-4402-437b-afa4-da012aa0c460/ir69nmo_thumbnail.png)
Transcribed Image Text:1 public class ClassC extends ClassB {
2 public ClassC() {
4
5
6
7
8
9
10
11
12
13
14
15}
9
10}
}
super();
}
public String toString() {
String temp = "";
for (int i = 0; i < strings.size(); i++) {
temp += "#" + strings.get(i) + "#";
if (i < strings.size() - 1) {
temp + "\n";
}
1 class TestClassC {
2
3
}
}
return temp;
public static void main(String[] args) {
ClassC myList = new ClassC();
myList.add("STOP");
myList.add("GO");
myList.add("TURN" );
O
System.out.print(myList);
System.out.println("all done");
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 53. Write a class with two instance variables, representing an old password and a new password. Write a recursive method that returns the number of places where the two passwords have different characters. The passwords can have different lengths. Write another, nonrecursive method returning whether the two passwords are sufficiently different. The method takes an int parameter indicating the minimum number of differences that qualify the passwords as being sufficiently different. Your program should include a client class to test your class.arrow_forwardWrite a JAVA program that will maintain a phone directory using Classes, and Objects. The programshould be able to perform the following operations:1.Add persons details (first name, last name, phone number, city, address, sex and email) to the phonedirectory, where phone numbers in the directory have to be unique. (Note: each person record will store inClasses and Objects)2.Update telephone number by providing person first name.3.Display all details of persons from a phone directory.4.Search telephone number based on person first name. (Note: use sequential search to find all telephonesfor the given first name)Project OutputsThe output has to display a menu of choices. Then the user can select which operation want to perform.Also, you can use the method System.exit(0); to exit the program. The menu of choices will be:1) Add person details into the telephone book.2) Update a telephone number by providing person first name.3) Display the entire telephone book.4) Search a telephone…arrow_forwardSuppose I have implemented classes C and D, where D extends C. “Just for fun” I want to write code such that a variable of type D refers to an object of type C. I’m allowed to use assignments, casts and so on. Explain why Java will make it impossible for me to achieve my goal.arrow_forward
- Write a Bank Account class in python to manage the account of the users. A user can deposit (add money) and withdraw (take money) money from his/her own account based on availability. At the time of account creation, the user has to provide his/her first name, last name, date of birth, NID number, contact number and address. Moreover, the user should deposit a minimum of 1000 taka to create the account. This money will be added to his account. After account creation the bank will give an account number to the user. The user should use this account number to access his account (show current balance, deposit and withdraw)arrow_forwardFirst, you need to design, code in Java, test and document a base class, Student. The Student class will have the following information: A. Title of the student (eg Mr, Miss, Ms, Mrs etc)B. A first name (given name)C. A last name (family name/surname)D. Student number (ID) – an integer number (of type long)E. A date of birth (in day/month/year format – three ints) - (Do NOT use the Date class from JAVA)The student class will have at least the following constructors and methods:(i) two constructors - one without any parameters (the default constructor), and one with parameters to give initial values to all the instance variables.(ii) a reasonable number of set and get methods.(iii) methods to compute the final overall mark and the final grade (which will be overridden in the respective child classes). These two methods will be void methods that set the appropriate instance variables. Remember one method can call another method. If you prefer, you can define a single method that sets…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education