C
Programming and Technical
Programming
Output
class bool test
{
public static void main(string[]args)
{
int result=0;
Boolean b1=new Boolean("true");
Boolean b2=new Boolean("true");
if(b1 equals(b2))
result=result+1000;
system.out.println("result="+result);
}
}
what will be output of this code...
a) result=0
b) result=1000
c) result=2000
d) none
Read Solution (Total 9)
-
- if(b1.equals(b2)) it means it checks the content of b1 and b2 bcz the content of both are same thats why its true and result=0+1000;
i.e, result=1000; - 9 years agoHelpfull: Yes(0) No(0)
- 1000
because result=0 then result=result+1000, 0+1000=1000 - 9 years agoHelpfull: Yes(0) No(0)
- a because they are compiled based on hash codes
- 9 years agoHelpfull: Yes(0) No(0)
- b) if(b1.equals(b2)) thn the content of b1 and b2 are same..
so result=0+1000=1000 - 9 years agoHelpfull: Yes(0) No(0)
- it will give error because the class name contain space i.?(bool test) . As we know that class name start with capital letter.
so its gives error - 9 years agoHelpfull: Yes(0) No(0)
- error...
it will give error because the class name contain space which is not possible in Java
- 9 years agoHelpfull: Yes(0) No(0)
- -> There is space in the name of the class which will produce an ERROR.
-> if there is no space then the answer will be 1000. - 9 years agoHelpfull: Yes(0) No(0)
- ANS: d
error will appear
there's no b1.equals - 9 years agoHelpfull: Yes(0) No(0)
- This is a java program.
It contains some errors
1)Strings in public void main should start with capital letter & it should String args[]
2)Capital of 's' in system.out.println
3)b1.equals(b2)
so ans is d
- 9 years agoHelpfull: Yes(0) No(0)
C Other Question