Tuesday, 20 May 2014

Java Operators Questions


What is the output of the following program?
class ModulusOperators1
{
    public static void main(String[] args)
    {
        double d=2.8;
        System.out.println("2.8%1.2 ="+ d%1.2);
    }
}

A.
0.4

B.
Compilation Error

C.
0

D.
None of the Above


What is the output of thefollowing program?
class Operators1
{
    public static void main(String[] args)
    {
        double x=6;
        int y=5,z=2;
        x= y++ + ++x/z;
        System.out.println(x);
    }
}

A.
9

B.
8

C.
8.5

D.
None of the Above

What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int x =5;
        x *=  2 +5;
        System.out.println(x);
    }
}



A.
15

B.
35

C.
Compilation Error

D.
None of the Above

What is the output of the following program?
class Class1
{
}
class Operators1
{
    public static void main(String[] args)
    {
        Class1 myobj= new Class1();
        System.out.println(myobj instanceof Operators1);
    }
}

A.
True

B.
False

C.
Compilation Error

D.
None of the Above

Java Operator Questions


What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int i=5,j;
        j=i++ + ++i;
        System.out.println("i="+i);
        System.out.println("j="+j);
    }
}


What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int i=5,j;
        j=i++ + ++i;
        System.out.println("i="+i);
        System.out.println("j="+j);
    }
}

What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int i=5,j;
        j=i + i++ + ++i;
        System.out.println("i="+i);
        System.out.println("j="+j);
    }
}

What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int i=5,j;
        j=i++ + i + ++i;
        System.out.println("i="+i);
        System.out.println("j="+j);
    }
}

What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int i=5,j;
        j=i++ + ++i + i;
        System.out.println("i="+i);
        System.out.println("j="+j);
    }
}

What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        double d=10;
        d=d<<2;
        System.out.println(d);
    }
}

What is the output of the following program?
lass Operators1
{
    public static void main(String[] args)
    {
        byte a=10;
        System.out.println(~a);

    }
}
What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        byte a=-20;
        System.out.println(~a);

    }
}


What is the output of the following program?
class BitWiseOps
{
    public static void main(String[] args)
    {
        int a=3, b=6;
        System.out.println((a|b) +" "+ (a&b) +" "+ (a^b));
    }
}
What is the output of the following program?
lass Operators1
{
    public static void main(String[] args)
    {
        int a=3, b=6;
    System.out.println((~a&b)|(a&~b));     
    }
}
What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int a=10, b=0;
        if( a > 10 && a/b == 10)
            System.out.println("Inside the If Condition!");
        System.out.println("Outside the If Condition!");
    }
}


What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int a=10, b=0;
        if( a == 10 && a/b == 10)
            System.out.println("Inside the If Condition!");
        System.out.println("Outside the If Condition!");
    }
}





What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int a=10, b=0;
        if( a <= 10 || a/b == 10)
            System.out.println("Inside the If Condition!");
        System.out.println("Outside the If Condition!");
    }
}
What is the output of the following program?
class Operators1
{
    public static void main(String[] args)
    {
        int a=10, b=0;
        if( a < 10 || a/b == 10)
            System.out.println("Inside the If Condition!");s
        System.out.println("Outside the If Condition!");
    }
}

Access attributes in component

NOTE: To access an attribute in a  component , use expressions as  {! v.<Attribute Name>} . ----------------------------------------...