what is the output ?
( 1 != 2 ) ? Yes : No
Answers
Answered by
5
Heya!
Here's your answer!
________________
____
The symbol != Means (not equal to)
This is the symbol usually used in programming questions :)
So ,
The question is asking :-
Is 1 not equal to 2?
Since in reality , 1 can never be = 2
Output:-
YES
_____________
____
Hope this helps!
Here's your answer!
________________
____
The symbol != Means (not equal to)
This is the symbol usually used in programming questions :)
So ,
The question is asking :-
Is 1 not equal to 2?
Since in reality , 1 can never be = 2
Output:-
YES
_____________
____
Hope this helps!
Answered by
6
heya friend,
According to your question ,
There should be NO output of the question because:
1)You haven't mentioned about the variable in which the result gets stored,
2)You haven't Written any printing statement(System.out.println).
BASICALLY THERE's A SYNTAX ERROR !!!!!
So neither the value gets stored nor you get output ,
Your question should have been like this
String a=( 1 != 2 ) ? "Yes" :" No";
System.out.println(a);
But, if you only want the result of ( 1 != 2 ) ? Yes : No
as
!= , it is NOT EQUAL TO OPERATOR
and since 1 is not equal to 2 , hence it is correct then the value stored should be Yes
then the answer is
Yes
As this is an easy example of ternary operator
Hope u understand!!!
thank you
According to your question ,
There should be NO output of the question because:
1)You haven't mentioned about the variable in which the result gets stored,
2)You haven't Written any printing statement(System.out.println).
BASICALLY THERE's A SYNTAX ERROR !!!!!
So neither the value gets stored nor you get output ,
Your question should have been like this
String a=( 1 != 2 ) ? "Yes" :" No";
System.out.println(a);
But, if you only want the result of ( 1 != 2 ) ? Yes : No
as
!= , it is NOT EQUAL TO OPERATOR
and since 1 is not equal to 2 , hence it is correct then the value stored should be Yes
then the answer is
Yes
As this is an easy example of ternary operator
Hope u understand!!!
thank you
Similar questions
Math,
8 months ago
Math,
8 months ago
Computer Science,
1 year ago
Science,
1 year ago
English,
1 year ago