Vidyalelo
Java Programming · all questions

Data Types and Variables
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

127

Questions

3/7

Page

Pick an option on a question to see the right answer and solution.

Determine output:
public class Test {
        static void test(float x){
                System.out.print("float");
        }

        static void test(double x){
                System.out.print("double");
        }

        public static void main(String[] args){
                test(99.9);
        }
}

Select an option to see the answer and solution.

The following fraction of code
double STATIC = 2.5 ;
System.out.println( STATIC );

Select an option to see the answer and solution.

What would be the output of the following fraction of code?
int Integer = 34 ;
char String = 'S' ;
System.out.print( Integer ) ;
System.out.print( String ) ;

Select an option to see the answer and solution.

What is the output of the following program?
public class Test{
	static int x  = 10 ;
       	public static void main(String[] a){
		 Test test = new Test( ) ; 
		 Test test1 = new Test( ) ;
		 test.x  +=  1 ;
		 System.out.println(  test.x + test1.x ) ;    
	}
}

Select an option to see the answer and solution.

What will be output of the following program code?
public class Test{
	public static void main(String[] a){
		short x = 10;
		x = x*5;
		System.out.print(x);
	}  
}

Select an option to see the answer and solution.

Determine output:
public class Test{
	int i = 34;
	public static void main(String args[]){
		Test t1 = new Test();
		Test t2 = new Test();
		t1.i = 65;
		System.out.print(t1.i);
		System.out.print(t2.i);
	}
}

Select an option to see the answer and solution.

The following program:
public class Test{ 
        static boolean isOK;
        public static void main(String args[]){
                System.out.print(isOK);
        } 
}

Select an option to see the answer and solution.

In Java, the word true is ................

Select an option to see the answer and solution.

What will the output of the following program?
public class Test{
      public static void main(String args[]){
            float f = (1 / 4) * 10;
            int i = Math.round(f);
            System.out.println(i);
      }
}

Select an option to see the answer and solution.

What is the output for the below code?
class A{
      int k;
      boolean istrue;
      static int p;
      public void printValue(){
            System.out.print(k);
            System.out.print(istrue);
            System.out.print(p);
      }
}

public class Test{
      public static void main(String argv[]){
            A a = new A();
            a.printValue();
      }
}

Select an option to see the answer and solution.

What is the output for the below code?
public class Test{
      int _$;
      int $7;
      int do;

      public static void main(String argv[]){
            Test test = new Test();
            test.$7=7;
            test.do=9;
            System.out.println(test.$7);
            System.out.println(test.do);
            System.out.println(test._$);
      }
}

Select an option to see the answer and solution.

What is the output for the below code?
public class Test{
      public static void main(String[] args){
            int i = 010;
            int j = 07;
            System.out.println(i);
            System.out.println(j);
      }
}

Select an option to see the answer and solution.

What is the output for the below code?
public class Test{
      public static void main(String[] args){
            byte b = 6;
            b+=8;
            System.out.println(b);
            b = b+7;
            System.out.println(b);
      }
}

Select an option to see the answer and solution.

What will be the output for the below code?
public class Test{
      public static void main(String[] args){
            byte i = 128;
            System.out.println(i);
      }
}

Select an option to see the answer and solution.

What will be the output for the below code?
public class Test{
      int i=8;
      int j=9;
      public static void main(String[] args){
            add();
      }
      public static void add(){
            int k = i+j;
            System.out.println(k);
     }
}

Select an option to see the answer and solution.

What will be output of following program?
public class Test{
      public static void main(String[] args){
            byte b=127;
            b++;
            b++;
            System.out.println(b);
      }
}

Select an option to see the answer and solution.

Determine output:
public class Test{
      int a = 10;
    
      public void method(int a){
            a += 1;
            System.out.println(++a);
      }
      public static void main(String args[]){
            Test t = new Test();
            t.method(3);
      }
}

Select an option to see the answer and solution.

Which class does all the Enums extend?

Select an option to see the answer and solution.

Which of the following is the advantage of BigDecimal over double?

Select an option to see the answer and solution.

What will be the output of the following Java code snippet?
double a = 0.02;
double b = 0.03;
double c = b - a;
System.out.println(c);

BigDecimal _a = new BigDecimal("0.02");
BigDecimal _b = new BigDecimal("0.03");
BigDecimal _c = b.subtract(_a);
System.out.println(_c);

Select an option to see the answer and solution.