Try to solve this conflict.

Morningdot Hablu

Morningdot Hablu

@morningdot-6Xuj4M Oct 25, 2024
It's my java examination question.
a=10,b=12;
Calculate the value of a&b and a&&b.

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • silverscorpion

    silverscorpion

    @silverscorpion-iJKtdQ Aug 5, 2010

    a & b = 8

    a = 10 = 1010
    b = 12 = 1100

    So, a & b is bitwise and, which comes to 1000 which is 8


    a && b is logical and. Since both operands are non zero, the result in 1.
  • vinsocorp

    vinsocorp

    @vinsocorp-4fscJ8 Aug 7, 2010

    a&b is 8.a&&b is 1...
  • Morningdot Hablu

    Morningdot Hablu

    @morningdot-6Xuj4M Aug 7, 2010

    You both are correct.