Answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Kryger [21]
2 years ago
6

Create a Flash Card class. Flash Cards have a Question and an Answer, each of which are Strings. Your class should include a con

structor, toString() and equals() methods. Write a main() method that creates an array of three Flash Cards, and prints each of them.
Computers and Technology
1 answer:
xeze [42]2 years ago
6 0

Answer:

<u> FlashCard.java</u>

  1. public class FlashCard {
  2.    String Question;
  3.    String Answer;
  4.    public FlashCard(String q, String a){
  5.        this.Question = q;
  6.        this.Answer = a;
  7.    }
  8.    public String toString(){
  9.        String output = "";
  10.        output += "Question: " + this.Question + "\n";
  11.        output += "Answer: " + this.Answer;
  12.        return output;
  13.    }
  14.    public boolean equals(String response){
  15.        if(this.Answer.equals(response)){
  16.            return true;
  17.        }
  18.        else{
  19.            return false;
  20.        }
  21.    }
  22. }

<u>Main.java</u>

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        FlashCard card1 = new FlashCard("What is highest mountain?", "Everest");
  4.        FlashCard card2 = new FlashCard("What is natural satelite of earth?", "Moon");
  5.        FlashCard card3 = new FlashCard("Who is the first president of US?", "George Washington");
  6.        FlashCard cards [] = {card1, card2, card3};
  7.        for(int i=0; i < cards.length; i++){
  8.            System.out.println(cards[i]);
  9.        }
  10.    }
  11. }

Explanation:

In FlashCard.java, we create a FlashCard class with two instance variable, Question and Answer (Line 2 - 3). There is a constructor that takes two input strings to initialize the Question and Answer instance variables (Line 5-8). There is also a toString method that will return the predefined output string of question answer (Line 10 - 15). And also another equals method that will take an input string and check against with the Answer using string equals method. If matched, return True (Line 17 -24).

In Main.java, create three FlashCard object (Line 3-5) and then put them into an array (Line 6). Use a for loop to print the object (Line 8-10). The sample output is as follows:

Question: What is highest mountain?

Answer: Everest

Question: What is natural satelite of earth?

Answer: Moon

Question: Who is the first president of US?

Answer: George Washington

You might be interested in
Which tool adds different amazing effects to a picture.
tatuchka [14]

Answer:

magic tool

Explanation:

4 0
1 year ago
Computerized simulations are run repeatedly on tropical storm and hurricane data. As a storm approaches land, these models predi
JulsSmile [24]

Answer:

c

Explanation:

Multiple sources that the forecaster or his crew has to put together to find out the stats of the storm.

4 0
1 year ago
Two forms of compression are lossy and lossless. State giving reasons which
Helen [10]

Answer:

(i) When transmitting a draft manuscript for a book, the lossless compression technique is most suitable because after decompression, the data is rebuilt and restored in its form as it was from where it originated

(ii) When transmitting a video recording which you have made of the school play, a lossy compression technique is most suitable because the large size of video files require the increased data carrying capacity which is provided by the lossy transmission technique. The quality of the video can be reduced without affecting the message intended to be delivered

Explanation:

4 0
1 year ago
_________ media must be downloaded in its entirety to the user's computer before it can be heard or seen
gladu [14]

Answer:

Downloadable

Explanation:

Cloud computing can be defined as a type of computing that requires shared computing resources such as cloud storage (data storage), servers, computer power, and software over the internet rather than local servers and hard drives.

Generally, cloud computing offers individuals and businesses a fast, effective and efficient way of providing services.

In Computer science, a downloadable media must first be downloaded in its entirety and saved to a user's computer before it can be played, heard or seen.

For example, for an end user to listen to a song hosted on a particular website, he or she must first of all download the song in its entirety and have saved on a computer system before it can be seen, played and listened to. Also, other downloadable media such as videos, animations, texts, etc., must be downloaded before they can be accessed or used by an end user.

4 0
1 year ago
For a color display using 8 bits for each of the primary colors (red, green, blue) per pixel, what should be the minimum size in
kodGreya [7K]
1st of all primary colors are red, yellow and blue. green is a secondary color
3 0
2 years ago
Other questions:
  • An object is identified by its<br>characteristics<br>state<br>class<br>attribute​
    13·1 answer
  • In a spreadsheet, cells B2 through B10 store the cost price of items and cells C2 through C10 store the selling price. If the se
    12·2 answers
  • Explain why a CPU’s speed is affected by the number of buses.
    5·1 answer
  • A(n) ______________ ________________ attack keeps the target so busy responding to a stream of automated requests that legitimat
    14·1 answer
  • In a ____________________ attack, the attacker sends a large number of connection or information requests to disrupt a target fr
    10·1 answer
  • Two programmers wrote very similar code. Compare the two to decide what the difference will be between them. Programmer A draws
    5·2 answers
  • Which is a connectionless protocol in the transport layer? What are the small chunks of data called?
    12·2 answers
  • What is computer software​
    9·1 answer
  • A speech that a person delivers without preparation is called
    12·1 answer
  • WAP to enter a multidigit number and find the sum of only even digits in a number.​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!