aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • Programming (C/C++)
  • int x = 2 * 3 + 4 * 5; What will be the value of x in the...
Multiple choice

int x = 2 * 3 + 4 * 5; What will be the value of x in the sample code?

  1. 22

  2. 26

  3. 46

  4. 50

  5. 70

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Operator precedence: * has higher precedence than +. So 2*3=6 and 4*5=20, then 6+20=26. The expression is evaluated as (2*3) + (4*5), not 2*(3+4)*5 or left-to-right.

Keep practicing — related questions

  • int x = 3; if( x == 2 ) x = 0; if( x == 3 ) x++; else x += 2; What value will x contain when the above samp...
  • int z,x=5,y=-10,a=4,b=2; z = x++ - --y * b / a; What will be the value of z in the sample code given above?
  • What is the value of x? int x = 8 / 3;
  • int z,x=5,y=-10,a=4,b=2; z = x++ - --y * b / a; What number will z in the sample code above contain?
  • int x=10,y; y=x++ + x++ + ++x; value of x and y?
  • Which of the following are legal lines of code? 1. int w = (int)888.8; 2. byte x = (byte)1000L; 3. long y =...
  • Which three are valid method signatures in an interface? 1. private int getArea(); 2. public float getVol(f...
  • switch(x) { default: System.out.println(Hello); } Which two are acceptable types for x? 1. byte 2. long 3. ...
Play the full quiz 🎤 Practise this topic out loud

Practice this topic

  • Programming Output Evaluation (1721 questions)
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy