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
What term is defined as private data placed in a packet with a header containing routing information that allows the data to tra
xeze [42]

Answer:

Encapsulation

Explanation:

Encapsulation is referring to the concept that data buding with some approach or method that is applied to that selected data.  it also restricts the use of some internal data of an object. The motive behind restricting the data is to prevent the misuse of the data.

For example- in java, encapsulation is refer to the wrapping of code with the data in one unit.

7 0
4 years ago
Supose that there are exactly 733 monks in the world.
kramer

A statement which is true about the monks is that: There is a day of the year that is the birthday of at least 3 monks.

<h3>What is a conditional statement?</h3>

A conditional statement can be defined as a statement that can be written to contain both a hypothesis and conclusion. Thus, it typically has the form "if P then Q."

Where:

P and Q represent sentences.

<h3>What is a converse statement?</h3>

A converse statement can be defined as a type of statement that is obtained by switching (reversing) the hypothesis and conclusion of a conditional statement. This ultimately implies that, the converse of a statement is obtained by switching (reversing) the hypothesis and  conclusion of a conditional statement.

In this context, we can reasonably infer and logically deduce that a statement which is true about the monks is that there is a day of the year that is the birthday of at least 3 monks because a year only has 365 days.

Read more on conditional statement here: brainly.com/question/16951916

#SPJ1

Complete Question:

Suppose that there are exactly 733 monks in the world.

Which one of the following statements is true about the monks?

Every day of the year, it's a monk's birthday.

There is a day of the year that is the birthday of exactly 3 monks

There is a monk who celebrates his birthday on a Tuesday

There is a day of the year that is the birthday of at least 3 monks

Some monk turns years at the weekend

None of the above.​

5 0
2 years ago
Was the big blue button thing a good decision or bad?<br> *I think it was a bad idea.
Gala2k [10]

sorry i just got banned so delete this answer plz i was banned and i wanted to see if they unbanned me

8 0
4 years ago
Read 2 more answers
Write the following function without using the C++ string class or any functions in the standard library, including strlen(). Yo
mixer [17]

Answer:

The function in C++ is as follows

int chkInd(string str1, string str2){    

int lenstr1=0;

while(str1[lenstr1] != '\0'){  lenstr1++;  }

int index = 0; int retIndex=0;

for(int i=lenstr1-1;i>=0; i--){

   while (str2[index] != '\0'){

       if (str1[i] == str2[index]){

           retIndex=1;

           break;         }

       else{   retIndex=0;      }

  index++;    }

  if (retIndex == 0){   return i;   }else{return -1;}}

}

Explanation:

This defines the function

int chkInd(string str1, string str2){    

First, the length of str1 is initialized to 0

int lenstr1=0;

The following loop then calculates the length of str1

while(str1[lenstr1] != '\0'){  lenstr1++;  }

This initializes the current index and the returned index to 0

int index = 0; int retIndex=0;

This iterates through str1

for(int i=lenstr1-1;i>=0; i--){

This loop is repeated while there are characters in str2

   while (str2[index] != '\0'){

If current element of str2 and str1 are the same

       if (str1[i] == str2[index]){

Set the returned index to 1

           retIndex=1;

Then exit the loop

           break;         }

If otherwise, set the returned index to 0

       else{   retIndex=0;      }

Increase index by 1

  index++;    }

This returns the calculated returned index; if no matching is found, it returns -1

  if (retIndex == 0){   return i;   }else{return -1;}}

}

5 0
3 years ago
Online transaction processing (OLTP) systems handle a company's routine ongoing business. In contrast, a data warehouse is typic
nataly862011 [7]

Online transaction processing (OLTP) systems handle a company's routine ongoing business. In contrast, a data warehouse is typically <u>a distinct system that provides storage for data that will be made use of in analysis.</u>

<u />

Explanation:

  • OLTP (Online Transactional Processing) is a category of data processing that is focused on transaction-oriented tasks. OLTP typically involves inserting, updating, and/or deleting small amounts of data in a database.
  • OLTP is an online database modifying system. OLAP is an online database query management system.
  • OLTP uses traditional DBMS. OLAP uses the data warehouse
  • OLTP mainly deals with large numbers of transactions by a large number of users
  • OLTP database systems are commonly used for order entry, financial transactions, customer relationship management and retail sales via the Internet.
  • Online Analytical Processing tools enable to analyze multidimensional data interactively from multiple perspectives.
5 0
3 years ago
Other questions:
  • Help thanks appreciate it
    12·1 answer
  • As Assembly language code runs on a CPU invoking functions and using the stack, it is clear that CPU registers are
    8·1 answer
  • HELP!!!!!!!! my keyboard keeps acting up every time I press a random key on my keyboard when it stops working it works perfectly
    9·1 answer
  • The purpose of a flowchart is similar to the purpose of pseudocode.<br> True<br> False
    5·2 answers
  • Which IP QoS mechanism involves prioritizing traffic? Group of answer choices IntServ RSVP COPS DiffServ None of the above
    14·1 answer
  • Which 2 tools are useful to remote employees and coworkers.
    10·1 answer
  • ___________________ has made the education process more effective and productive.
    10·2 answers
  • A relational database can best be described as a collection of related _____ designed to minimize redundant data.
    5·1 answer
  • The scope of a temporary table is limited to what?
    10·1 answer
  • As data travels further over a wavelength or frequency, what goes down?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!