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
vitfil [10]
3 years ago
11

This semester we looked at three languages (C++, Java and Python). One common rule in all three class checklists (for C++, Java

and Python) was a logical equivalence (equals) function. In C++ it was operator==; in Java it was equals; and in Python it was __eq__. Why does this rule exist in all three languages?
Computers and Technology
1 answer:
Marysya12 [62]3 years ago
5 0

Answer:

The languages C++, Java, Python are Object Oriented Programming languages. What this means is that we create classes and then instantiate those classes. In C++ and Java, we use the new operator to instantiate the classes. So, if we want to display some data when we try to print the instance just like we print the variables of data types like int, double, string etc, we need to define what we need to display. It is because, class are just like data types like int, double etc. But as they are defined by the developer according to his/her needs, so the developer has to define what to print when they are printed.

You might be interested in
What is the purpose of a turbine in a power plant?
anastassius [24]
C. To make the generator work

4 0
2 years ago
Create a class called Clock to represent a Clock. It should have three private instance variables: An int for the hours, an int
Anvisha [2.4K]

Answer:

public class Clock

{

private int hr; //store hours

private int min;  //store minutes

private int sec; //store seconds

public Clock ()

{

 setTime (0, 0, 0);

}

public Clock (int hours, int minutes, int seconds)

{

 setTime (hours, minutes, seconds);

}

public void setTime (int hours, int minutes, int seconds)

{

 if (0 <= hours && hours < 24)

      hr = hours;

 else

      hr = 0;

 

 if (0 <= minutes && minutes < 60)

      min = minutes;

 else

      min = 0;

 

 if (0 <= seconds && seconds < 60)

      sec = seconds;

 else

      sec = 0;

}

 

 //Method to return the hours

public int getHours ( )

{

 return hr;

}

 //Method to return the minutes

public int getMinutes ( )

{

 return min;

}

 //Method to return the seconds

public int getSeconds ( )

{

 return sec;

}

public void printTime ( )

{

 if (hr < 10)

      System.out.print ("0");

 System.out.print (hr + ":");

 if (min < 10)

      System.out.print ("0");

 System.out.print (min + ":");

 if (sec < 10)

      System.out.print ("0");

 System.out.print (sec);

}

 

 //The time is incremented by one second

 //If the before-increment time is 23:59:59, the time

 //is reset to 00:00:00

public void incrementSeconds ( )

{

 sec++;

 

 if (sec > 59)

 {

  sec = 0;

  incrementMinutes ( );  //increment minutes

 }

}

 ///The time is incremented by one minute

 //If the before-increment time is 23:59:53, the time

 //is reset to 00:00:53

public void incrementMinutes ( )

{

 min++;

 

if (min > 59)

 {

  min = 0;

  incrementHours ( );  //increment hours

 }

}

public void incrementHours ( )

{

 hr++;

 

 if (hr > 23)

     hr = 0;

}

public boolean equals (Clock otherClock)

{

 return (hr == otherClock.hr

  && min == otherClock.min

   && sec == otherClock.sec);

}

}

3 0
2 years ago
You are now going to prepare some reports for the company. Measurements are in metres and volume
romanna [79]

if you follow me and like and mark in brainliest answer only I will tell the answer

4 0
2 years ago
HELP PLZZ WILL MARK BRAINLIEST
adoni [48]

Answer:

if you could capture another image of this work bc I cant make out some words I can barley make out words

4 0
3 years ago
Create a game that rolls two dies (number from 1 to 6 on the side) sequentially for 10 times (use loop). If at least once out of
Alex73 [517]

Answer:

Explanation:

The following code is written in Java and loops through 10 times. Each time generating 2 random dice rolls. If the sum is 10 it breaks the loop and outputs a "You Win" statement. Otherwise, it outputs "You Lose"

import java.util.Random;

class Brainly {

   public static void main(String[] args) {

       UseRandom useRandom = new UseRandom();

       boolean youWin = false;

       for (int x = 0; x<10; x++) {

           int num1 = useRandom.getRandom(6);

           int num2 = useRandom.getRandom(6);

           if ((num1 + num2) == 10) {

               System.out.println("Number 1: " + num1);

               System.out.println("Number 2: " + num2);

               System.out.println("You Win");

               youWin = true;

               break;

           }

       }

       if (youWin == false) {

           System.out.println("You Lose");

       }

   }

}

class UseRandom{

   public int getRandom(int n)

   {

       Random r=new Random();

       int rand=r.nextInt(n);

       return rand;

   }}

8 0
2 years ago
Other questions:
  • 1.
    13·1 answer
  • What are three requirements of information technology a. Accuracyb. _______________________________c. __________________________
    13·1 answer
  • Consider the most important item among all the categories of information stored on your personal computer. As it applies to that
    8·1 answer
  • The best way to achieve stronger encryption is to
    13·1 answer
  • "background" software that helps the computer manage its own internal resources is called ________.
    5·1 answer
  • The architecture in which the database resides on a back-end machine and users access data through their workstations is
    5·2 answers
  • Lets say if my computer shut down every 10 minutes. What can you do to solve the problem. Hint: Use these word in you answer: ha
    10·2 answers
  • I need help about computer program. Solve C language code...... please​
    7·1 answer
  • Imagine that a team of scientists test a certain hypothesis, and the experimental results show that it is false.
    6·1 answer
  • Help plz (will give brainliest)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!