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
irina [24]
3 years ago
12

Given the following sequence of Java code: int var1 = 0b0001; int var2 = 0b1111; int results1 = var1 & var2; int results2 =

var1 | var2; int results3 = var1 ^ var2; int printit = results1 + results2 + results3; What are the values for results1, results2, results3 and printit after executing the code?
Computers and Technology
1 answer:
marusya05 [52]3 years ago
4 0

Answer:

results1 = 1

results2 = 15

results3 = 14

printit = 30

Explanation:

public class HelloWorld{

    public static void main(String []args){

       int var1 = 0b0001;

       int var2 = 0b1111;

       int results1 = var1 & var2;

       int results2 = var1 | var2;

       int results3 = var1 ^ var2;

       int printit = results1 + results2 + results3;

       System.out.printf("%d %d %d %d", results1, results2, results3, printit);

    }

}

Output:

$javac HelloWorld.java

$java -Xmx128M -Xms16M HelloWorld

1 15 14 30

In this program we are performing binary operations with logical gates and binary numbers, to understand the result see each binary operation:

  • var1 & var2: refers to the AND gate, since 0001 & 1111 is 0001 our result as an integer is 1
  • var1 | var2: refers to the OR gate, since 0001 | 1111 is 1111 our result as an integer is 15
  • var1 ^ var2: refers to the XOR gate, since 0001 ^ 1111 is 1110 our result as an integer is 14
  • results1 + results2 + results3: refers to the sum of 3 integers, 1+15+14 equal 30
You might be interested in
100 points, PLEASE HELP...To generate numbers between and including -10 to 10 you would use:
Orlov [11]

Answer:

A number line?

6 0
3 years ago
In this lab, you use the flowchart and pseudocode found in the figures below to add code to a partially created C++ program. Whe
never [62]

Answer:

The equivalent program in C++:

#include<iostream>

#include <sstream>

using namespace std;

int main(){

   string Score, Rank;

   cout<<"Enter student score and class rank: ";

   cin>>Score>>Rank;

   int testScore = 0, classRank = 0;

   stringstream sstream(Score);

   sstream>>testScore;

   

   stringstream tream(Rank);

   tream>>classRank;

   

   if (testScore >= 90){

       if(classRank >=25){cout<<"Accept";}

       else{cout<<"Reject";}

   }

   else if(testScore >= 80){

       if(classRank >=50){cout<<"Accept";}

       else{cout<<"Reject";}

   }

   else if(testScore >= 70){

       if(classRank >=75){cout<<"Accept";}

       else{cout<<"Reject";}

   }

   else{cout<<"Reject";}

   return 0;

}

Explanation:

This declares Score and Rank as string variables

   string Score, Rank;

This prompts the user for score and class rank

   cout<<"Enter student score and class rank: ";

This gets the user input

   cin>>Score>>Rank;

This declarees testScore and classRank as integer; and also initializes them to 0

   int testScore = 0, classRank = 0;

The following converts string Score to integer testScore

<em>    stringstream sstream(Score);</em>

<em>    sstream>>testScore;</em>

The following converts string Rank to integer classRank

   stringstream tream(Rank);

   tream>>classRank;

The following conditions implement the conditions as given in the question.    

If testScore >= 90

<em>    if (testScore >= 90){</em>

If classRank >=25

<em>        if(classRank >=25){cout<<"Accept";}</em>

If otherwise

<em>        else{cout<<"Reject";}</em>

<em>    } ---</em>

If testScore >= 80

<em>    else if(testScore >= 80){</em>

If classRank >=50

<em>        if(classRank >=50){cout<<"Accept";}</em>

If otherwise

<em>        else{cout<<"Reject";}</em>

<em>    }</em>

If testScore >= 70

<em>    else if(testScore >= 70){</em>

If classRank >=75

<em>        if(classRank >=75){cout<<"Accept";}</em>

If otherwise

<em>        else{cout<<"Reject";}</em>

<em>    }</em>

For testScore less than 70

<em>    else{cout<<"Reject";}</em>

<em />

3 0
2 years ago
Which architecture for deploying a firewall is most commonly used in businesses today? Why?
zmey [24]

Answer:Screened Subnet Firewall

Explanation:Screened Subnet Firewalls is the firewall deploying mechanism that is used at the present time in the organizational area.It is used as because it is supposed to be a good option as it protects the networks and DMZ operating system from any kind of virus that can damage the connection. It works as the security section and protects the system.

8 0
3 years ago
A technician is troubleshooting a small network with cable Internet service in which a user is receiving a message in her web br
expeople1 [14]

Answer:

Option E is correct.

Explanation:

A professional is fixing a cable internet access network by which a person in their internet browser receives a text saying that a link could not be reached. It would be known that each and every server along the network is having the individual problem across whole websites when interviewing a person.

So, connect the system to the wired connection directly, & try to access the internet for troubleshooting the following issue.

6 0
3 years ago
How can solve a Boolean algebra problem?<br><br> Ex: JK+(~J+~K)L+JK
kicyunya [14]
I am not sure what you mean by that but a boolean is either true or false. So it is kind of like a true or false question. 4+4=7 is false. 2*4!=48 is true.
8 0
3 years ago
Other questions:
  • At an uncontrolled intersection, you should yield to the car on the right. True or false.
    10·2 answers
  • ____ are the computers that store network software and shared or private user files.
    6·1 answer
  • The _________ check is a type of hardware control that involves adding a "1" or a "0" to the end of every 8 bit byte such that t
    11·1 answer
  • Write a program that continually prompts the user for an integer input until input is entered that is less than 0. Each input th
    9·1 answer
  • Retrieve the names of employees who work on exactly one project that is controlled by their department. (It does not matter how
    7·1 answer
  • How many Iron molecules are in the compound Fe4O2?
    15·2 answers
  • On start up, which of these windows is not displayed ?
    15·2 answers
  • Brainliest For Tascake Because People Texted Before Tascake Could<br><br> Hurry Tascake
    13·2 answers
  • Were is the hype house
    5·2 answers
  • Gabby is creating a game in which users must create shapes before the clock runs out. Which Python module should Gabby use to cr
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!