Monday, May 11, 2009

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:

About This Blog

This Blog is all about Java and programming.This blog is written by Vaibhav Pandey .He is a Computer Science Graduate .You can contact the author at javatute@gmail.com for any suggestion or Query.You can also contact the author for advertising on this blog.All the material presented here is the property of author and its reproduction in any form is strictly prohibited.

Disclaimer:-Download links provided here are not of author in any means.These are found over the Internet.
Page copy protected against web site content infringement by Copyscape

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP