1answer.
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
vivado [14]
3 years ago
12

Consider the following implementation of a class Square:

Computers and Technology
1 answer:
DaniilM [7]3 years ago
4 0

Answer:

The answer to this question can be given as:

Code:

class Square   //define class Square

{

Private int sideLength;  //define variable  

Square(int length)   //define parameterized constructor.        

{

sideLength = length;        //hold value of the parameter

}

int getArea()                  //define function getArea.

{

Private int area;            //define variable.

area = sideLength * sideLength;          //calculate area.

return area;            //return value.

}

}

Explanation:

In this question it is not a good idea to introduce an instance variable for the area because It may be a different method that defines the same variable with the same name but different variables because they are related to different functions, so it is better to make this variable local in this case.

You might be interested in
A palindrome is a string that reads the same from left to right and from right to left. Design an algorithm to find the minimum
stepladder [879]

Answer:

Explanation:

The following code is written in Python. It is a recursive function that tests the first and last character of the word and keeps checking to see if each change would create the palindrome. Finally, printing out the minimum number needed to create the palindrome.

import sys

def numOfSwitches(word, start, end):

   if (start > end):

       return sys.maxsize

   if (start == end):

       return 0

   if (start == end - 1):

       if (word[start] == word[end]):

           return 0

       else:

           return 1

   if (word[start] == word[end]):

       return numOfSwitches(word, start + 1, end - 1)

   else:

       return (min(numOfSwitches(word, start, end - 1),

                   numOfSwitches(word, start + 1, end)) + 1)

word = input("Enter a Word: ")

start = 0

end = len(word)-1

print("Number of switches required for palindrome: " + str(numOfSwitches(word, start, end)))

3 0
3 years ago
Which of the following best describes the safety of blogging
Pavlova-9 [17]
We need the options
3 0
3 years ago
Some of y'all make me lose braincells with your questions
boyakko [2]

Answer:

ok done we will try

BTW have a nice day enjoy your day Stay blessed stay happy stay strong

5 0
2 years ago
Read 2 more answers
​your business has a web server that has suddenly become unresponsive. when you study the server's logs there are a huge number
kvasek [131]
there's a chance the web server could quite possibly be backed up from all the requests and not being cleaned or updated often
8 0
3 years ago
Read 2 more answers
When you hear music, read a printout, or view a video, you are using a computer's
Alik [6]

Answer:

Output device.

Explanation:

An output device can be defined as a hardware device that typically receives processed data from the central processing unit (CPU) and converts these data into information that can be used by the end user of a computer system.

All of the output device of a computer are known as peripheral devices and they provide data (informations) to the end users in various formats such as video, audio, texts, images etc.

Since output devices are peripheral devices, they can be connected to the computer system wirelessly or through a wired-connection (cable).

Some examples of output devices are monitor, speakers, printer, projector etc.

Hence, when you hear music, read a printout, or view a video, you are using a computer's output device.

5 0
3 years ago
Other questions:
  • Very large and very small numbers are easier to write in scientific notation. For example, the number, 0.000000728 would be writ
    7·1 answer
  • Several coworkers in the sales department received an email claiming to be from you. Each message was personally addressed and c
    11·1 answer
  • Create an application named TurningDemo that creates instances of four classes: Page, Corner, Pancake, and Leaf. Create an inter
    7·1 answer
  • How do you respond to an email?
    6·1 answer
  • Suppose a host has a 1-MB file that is to be sent to another host. The file takes 1 second of CPU time to compress 50%, or 2 sec
    12·1 answer
  • Write a program to create a customer bill for a company. The company sells only five products: TV, DVD player, Remote Controller
    12·1 answer
  • Upon connecting to a Wi-Fi network, you're redirected to a login screen and a request to accept terms of service before being co
    15·1 answer
  • Which online note-taking device allows students to clip a page from a website and reuse it later?
    13·2 answers
  • The FCFS algorithm is particularly troublesome for ____________.
    13·1 answer
  • Edit the program provided so that it receives a series of numbers from the user and allows the user to press the enter key to in
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!