Computer Science, asked by GeekyJS, 10 months ago

what will the final values be stored in variables when executed?

double a = -99.51;

double b = -56.25;


i) double p = Math.abs(Math.floor(a));

ii) double q = Math.sqrt(Math.abs(b));

iii) double r = Math.rint(Math.abs(b));​

Answers

Answered by SwatiMukherjee
5

Answer:

A data type is a set of values and a set of operations defined on them. For example, we are familiar with numbers and with operations defined on them such as addition and multiplication. There are eight different built-in types of data in Java, mostly different kinds of numbers. We use the system type for strings of characters so frequently that we also consider it here.

Terminology. We use the following code fragment to introduce some terminology:

int a, b, c; a = 1234; b = 99; c = a + b;

The first line is a declaration statement that declares the names of three variables using the identifiers a, b, and c and their type to be int. The next three lines are assignment statements that change the values of the variables, using the literals 1234 and 99, and the expression a + b, with the end result that c has the value 1333.

Characters and strings. A char is an alphanumeric character or symbol, like the ones that you type. We usually do not perform any operations on characters other than assigning values to variables. A String is a sequence of characters. The most common operation that we perform on strings is known as concatenation: given two strings, chain them together to make a new string. For example, consider the following Java program fragment:

String a, b, c; a = "Hello,"; b = " Bob"; c = a + b;

The first statement declares three variables to be of type String. The next three statements assign values to them, with the end result that c has the value "Hello, Bob". Using string concatenation,Ruler.java prints the relative lengths of the subdivisions on a ruler.

Integers. An int is an integer (whole number) between −231 and 231 − 1   (−2,147,483,648 to 2,147,483,647). We use ints frequently not just because they occur frequently in the real world, but also they naturally arise when expressing algorithms. Standard arithmetic operators for addition, multiplication, and division, for integers are built into Java, as illustrated in IntOps.java and the following table:

Floating-point numbers. The double type is for representing floating-point numbers, e.g., for use in scientific applications. The internal representation is like scientific notation, so that we can compute with real numbers in a huge range. We can specify a floating point number using either a string of digits with a decimal point, e.g., 3.14159 for a six-digit approximation to the mathematical constant pi, or with a notation like scientific notation, e.g., 6.022E23 for Avogadro's constant 6.022 × 1023. Standard arithmetic operators for addition, multiplication, and division, for doubles are built in to Java, as illustrated in DoubleOps.java and the following table:

Quadratic.java shows the use of doubles in computing the two roots of a quadratic equation using the quadratic formula.

Booleans. The boolean type has just two values: true or false. The apparent simplicity is deceiving—booleans lie at the foundation of computer science. The most important operators defined for the boolean are for and, or, and not.

and:  a && b is true if both aand b are true, and false otherwise.or:  a || b is true if either a or bis true (or both are true), and false otherwisenot:  !a is true if a is false, and false otherwise.

Although these definitions are intuitive and easy to understand, it is worthwhile to fully specify each possibility for each operation in a truth table.

Comparisons. The comparisonoperators are mixed-typeoperations that take operands of one type (e.g., int or double) and produce a result of type boolean. These operations play a critical role in the process of developing more sophisticated programs.

  • PLEASE MARK ME AS A BRAIN LIST...

Similar questions