Simple Java Twisters
Hi guys I am back after giving away the so called tough exam "The advanced computer architecture".That was fine but I am not enjoyed it at all.But here are some twisters you guys must enjoy, at first sight they seem simple but mind you they are very simple to twist you.Check them out.These twisters surely gonna test your program understanding capabilities, so be prepared.If you think you got the answers right then check on your own ,just copy this code and try to run it on your system.If you got answers matched with yours then you are not twisted by them else no worries just try to make your basics strong.Some guys will find these questions really easy but I must say these are just for guys who want some fun from programming.
Here they come:-
1.What would be the output of following code segment
public class test
{
public static void main(String a[])
{
boolean x;
if(x=true)
System.out.println("This is true");
else
System.out.println("This is false");
}
}
2.What would be the output of following code:-
public class maintest
{
public static int main(String a[])
{
int x=10;
if(x++)
System.out.println(x++);
else
System.out.println(++x);
}
}
3.What would be the output of following code:-
public class inttest
{
public static void main(String a[])
{
int x=20;
if(x==x++)
System.out.println("This is true");
else
System.out.println("This is false");
}
}
4.What would be the output of following code:-
public class inttest4
{
public static void main(String a[])
{
int x=20;
if(x+1 ==((x++ + ++x)/2))
System.out.println("This is true");
else
System.out.println("This is false");
}
}
5.What would be the output of following code:-
public class inttest3
{
public static void main(String a[])
{
int x=20;
if(x+1 ==((++x + x++)/2))
System.out.println("This is true");
else
System.out.println("This is false");
}
}
6.what would be the output of following code:-
public class inttest2
{
public static void main(String a[])
{
int x=20;
if(x==++x)
System.out.println("This is true");
else
System.out.println("This is false");
}
}
Links:-
Home
Earn money Quick


















0 comments:
Post a Comment
Post a Comment