0

programming languages Online Quiz - 214

Description: programming languages Online Quiz - 214
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Who can access a method if it is marked as protected internal ?

  1. Classes that are both in the same assembly and derived from the declaring class.

  2. Only methods that are in the same class as the method in question.

  3. Classes within the same assembly, and classes derived from the declaring class.

  4. Classes in different assembly


Correct Option: C

Output of this program : class type { int num=12; void setnum(int num){ num=num; } int getnum() { return num; } public static void main(String[] args){ type obj=new type(); obj.setnum(10); System.out.print(obj.getnum()); } }

  1. 10

  2. 12

  3. compilation error

  4. none of these


Correct Option: B
  1. 8 bit

  2. 1 bit

  3. machine dependent

  4. none of these


Correct Option: C

Correct way of method declaration within interface :

  1. void run();

  2. protected void go();

  3. public abstract set();

  4. none of these


Correct Option: A
  1. interface declares constant and instance variables.

  2. The abstract modifier can be combined with the static modifier .

  3. native modifier can be applied only on method.

  4. synchronized modifier can be applied to method as well as class

  5. none of these


Correct Option: C

Which program will give correct output :

  1. class cons{ cons() { } public void cons(); public static void main (String[] aa){ cons b=new cons(); } }

  2. public class cons { ............... cons() { } public cons(int x,int y) { System.out.print(x +" "+ y); } public static void main (String[] aa){ cons b=new cons(); cons obj=new cons(4,2); }

  3. public class cons { public cons(int x) { System.out.print(x); } public static void main (String[] aa){ cons b=new cons(); } }

  4. class cons{ cons() { } public float foo () { double f = 32; return f; } public static void main (String[] aa){ cons b=new cons(); } }


Correct Option: B

Output of this program : class type { int num=12; void setnum(int num){ num=num; } int getnum() { return num; } public static void main(String[] args){ type obj=new type(); obj.setnum(10); System.out.print(obj.getnum()); } }

  1. 10

  2. 12

  3. compilation error

  4. none of these


Correct Option: B
  1. 8 bit

  2. 1 bit

  3. machine dependent

  4. none of these


Correct Option: C
  1. void run();

  2. protected void go();

  3. static void get();

  4. public abstract set();

  5. none of these


Correct Option: A
  1. interface declares constant and instance variables.

  2. The abstract modifier can be combined with the static modifier .

  3. native modifier can be applied only on method.

  4. synchronized modifier can be applied to method as well as class.

  5. none of these


Correct Option: C

Which program will give correct output :

  1. class cons{ cons() { } public void cons(); public static void main (String[] aa){ cons b=new cons(); } }

  2. public class cons { cons() { } public cons(int x,int y) { System.out.print(x +" "+ y); } public static void main (String[] aa){ cons b=new cons(); cons obj=new cons(4,2); } }

  3. public class cons { public cons(int x) { System.out.print(x); } public static void main (String[] aa){ cons b=new cons(); } }

  4. class cons{ cons() { } public float foo () { double f = 32; return f; } public static void main (String[] aa){ cons b=new cons(); } }


Correct Option: B
  1. A static method may override another static method

  2. A static method cannot override a non-static method

  3. A non-static method cannot override a static method

  4. A non-static method may be overloaded by a static method

  5. A synchronized method cannot be overridden


Correct Option: B,C,D

What will be output for the following program? public class Boxing2 { public static void main(String[] args) { byte b = 10; method(b); } static void method(int i){ System.out.println("Primitivae Type call"); } static void method(Integer i){ System.out.println("Wrapper Type Call"); } }

  1. Wrapper Type Call

  2. Primitive Type Call

  3. Compiler Error

  4. Compiles fine, throws runtime exception


Correct Option: B

What will be the output of the following program? public class Ques09 { public static void main(String[] args) { Integer a = null; a = new Integer(10); int b = 20; a = b; a = 30; System.out.println(a++); short s = 100; a = s; System.out.println(a--); } }

  1. The program won't compile.

  2. The program will throw a run-time exception.

  3. The program will output '31 100'

  4. The program will output '31 99'


Correct Option: A
- Hide questions