Computer Science, asked by sanjeevkanchanmishra, 3 months ago

Please solve this worksheet fast please​

Attachments:

Answers

Answered by anindyaadhikari13
6

Required Solution:-

Question 2:

➡ Output for the following.

Part a:

Given that,

>> x = 5

  1. 5 * ++x = 5 * 6 = 30
  2. 5 * x++ = 5 * 5 = 25 (Now, x = 6)

Part b:

Given that,

>> m = 17

>> n = 17

  1. ++m % n++ = 18 % 17 = 1 (Now, n = 18)
  2. n+=n++ >> n = n + n++ >> n = 17 + 17 = 34(post increment)
  3. ++m % ++n = 18%18 = 0

Explanation:

There are two types increment and decrement operator, postfix and prefix.

  • Prefix Increment/Decrement: When increment or decrement operator is used before the operand, it is known as prefix operator. Here, the value of the variable increments by 1 and then the operation takes place.

  • Postfix Increment/Decrement: When increment or decrement operator is used after the operand, it is known as postfix operator. Here, the operation takes place first and after that the value of the variable is incremented.

Question 3:

  • Definition of token

Answer:

  • The smallest individual/meaningful/fundamental unit in a programming statement is known as token.
  • The various types of token namely, Literals, Identifiers, Assignments, Punctuators, Separators, Operators and Keywords.

Question 4:

  • Definition of Bytecode.

Answer:

  • Java complier coverts Java source code into an intermediate binary code. This code is called Bytecode. Bytecodes can't be executed directly on the processor. It needs to be converted into Machine Code at first.
  • JVM (Java Virtual Machine) is the software that converts Bytecode into Machine code. It is platform specific.

Question 5:

  • Definition of literals.

Answer:

  • Literals are the constants whose value remains fixed(do not alter) during the execution of program.
  • There are six types of literals in Java, viz. Integer Literal, Real Literal, Character Literal, String Literals, Boolean Literals, and Null Literals.

Question 6:

  • Java expression for (-b ±√b²-4ac)/2a

Answer:

There is no ± sign in Java. You can assign in two separate variables.

x = (-b + Math.sqrt(b*b - 4*a*c))/(2*a) and,

y = (-b - Math.sqrt(b*b - 4*a*c))/(2*a)

Question 7:

  • Output for the expressions.

Answer:

  • Math.ceil(5.3) = 6.0
  • Math.ceil(5.5) = 6.0
  • Math.floor(5.6) = 5.0
  • Math.floor(5.5) = 5.0
  • Math.round(8.9) = 9
  • Math.round(4.5) = 5

Explanation:

  • Math.ceil():- Used to return the higher integer for the given argument.
  • Math.floor():- Used to return the lower integer for the given argument.
  • Math.round():- Used to return the rounded form of the value.
Similar questions