Thursday, April 9, 2020

Java Output Questions set - 1


Set – 1
Java output questions:

1.class Test
class Bitwise
{
    public static void main(String [] args)
    {
        int x = 11 & 9;
        int y = x ^ 3;
        System.out.println( y | 12 );
    }
}
A.0
B.7
C.8
D.14

2.class Test
public class Test
{
    public static void leftshift(int i, int j)
    {
        i <<= j;
    }
    public static void main(String args[])
    {
        int i = 4, j = 2;
        leftshift(i, j);
        System.out.printIn(i);
    }
}
A.2
B.4
C.8
D.16

3.public class App
{
    public static void main( String[] args )
    {
        short x = 1;
        int i = 123456;
        x = x + i;
        System.out.println(x);
    }
}
A.123457
B.Runtime Error
C.Compilation Error
D.None of these

4.class Test
class SSBool
{
    public static void main(String [] args)
    {
        boolean b1 = true;
        boolean b2 = false;
        boolean b3 = true;
        if ( b1 & b2 | b2 & b3 | b2 )
            System.out.print("first ");
        if ( b1 & b2 | b2 & b3 | b2 | b1 )
            System.out.println("second");
    }
}
A.first
B.second
C.first second
D.Compilation Error

5.public class Prg {
 public static void main(String args[]){
  System.out.print("A" + "B" + 'A');
 }
}
A.ABA
B.AB65
C.Error
D.AB

6.public class Prg {
    public static void main(String args[]){
        System.out.print(20+ 1.34f + "A" + "B");
    }
}
A.201.34AB
B.201.34fAB
C.21.34AB
D.Error

7.public class prg {
    public static void main(String[] args) {
        System.out.print("Hello");
        System.out.println("Guys!");
    }
}
A.HelloGuys!
B.Hello Guys!
C.Hello
D.Guys!
E.Compile with a Warning

8.public class MyPrg
{
    public static void main(String args[])
    {
        System.out.print("IncludeHelp");

    }
}
A.MyPrg.class
B.MyPrg.java
C.MyPrg
D.Any file name with java extension

9.class Prg
{
    public static void main(String args[])
    {
        const int a=10;
        System.out.println(a);

    }
}
A.10
B.a
C.Unprintable Character
D.Error

10.public class Prg {
    public static void main(String[] args) {
        char [] str={'i','n','c','l','u','d','e','h','e','l','p'};
        System.out.println(str.toString());
    }
}
A.includehelp
B.Error
C.[C@19e0bfd (Memory Address)
D.NULL



No comments:

Post a Comment

Python Technical Interview Questions

 1)first non repeating character Malayalam y programming p str = "MalayalaM" a = '\0' for c in str:     if str.index(c) ==...