0

programming languages Online Quiz - 272

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

void main(){ char far *p = 0x417; *p=64; }

  1. Reboot the Machine

  2. Disable the print screen key

  3. Change the default screen color

  4. puts Capslock on


Correct Option: D

void main() { int a[2][3]={{1,2,3},{4,5,6}}; printf("%d\n",++**(a+1)); }

  1. 5

  2. garbage value

  3. compile error

  4. 2


Correct Option: A

Which of the following operator when used with numbers is not efficient ?

  1. NOT >

  2. NOT

  3. NOT =

  4. None of the above


Correct Option: C
  1. null

  2. Primary Key class

  3. Home Object

  4. Remote Object


Correct Option: A

Which of the following statements hold true in the following program? package generics; import java.util.ArrayList; import java.util.List; public class Ques04 { public static void main(String[] args) { List extends Instrument> allInstruments = new ArrayList(); // -->X allInstruments.add(new Guitar()); allInstruments.add(new Violin()); } } interface Instrument { public void play(); } class Guitar implements Instrument { public void play(){ System.out.println("Playing Guitar."); } } class Violin implements Instrument { public void play(){ System.out.println("Playing Violin."); } }

  1. The program will not compile.

  2. The program will compile but will throw run-time exception.

  3. The statement 'X' manifests that objects of type Instrument as well as sub-types can be added to the list 'allInstruments'.

  4. It is not possible to add any type of objects to the list 'allInstruments'.


Correct Option: A
  1. The Session is not valid in the new Window

  2. The Session is valid in the new Window

  3. The Scope is not valid in the new Window

  4. The Scope is valid in the new Window


Correct Option: B

What is the output for the following lines of code? import java.io.*; public class FileHandling { public static void main (String[] arg) throws Exception { File f = new File ("ll.txt"); FileOutputStream s = new FileOutputStream(f); PrintStream p = new PrintStream (s); p.println("hi"); } }

  1. A. It would fail to compile

  2. B. It would generate a run-time error on execution.

  3. C. It would execute, but ask the user to specify the directory in which to create ll.txt.

  4. D. It would execute without an error and print "hi" to a file called ll.txt


Correct Option: D
  1. A) Strings are immutable, compilation error at line 3.

  2. B) Strings are immutable, runtime exception at line 3.

  3. C) Prints "Welcome".

  4. D) Prints "Welcome to Java!".


Correct Option: C

What is the output for the following lines of code? 1: public class Q8 2: { 3: int i = 20; 4: static 5: { 6: int i = 10; 7: 8: } 9: public static void main(String[] args) 10: { 11: Q8 a = new Q8(); 12: System.out.println(a.i); 13: } 14: }

  1. Compilation error, variable "i" declared twice.

  2. Compilation error, static initializers for initialization purpose only.

  3. Prints 10.

  4. Prints 20.


Correct Option: D

Which method names follow the JavaBeans standard?

  1. addSize

  2. getCust

  3. deleteRep

  4. putDimensions


Correct Option: B

class Fizz { int x = 5; public static void main(String[] args) { final Fizz f1 = new Fizz(); Fizz f2 = new Fizz(); Fizz f3 = FizzSwitch(f1,f2); System.out.println((f1 == f3) + " " + (f1.x == f3.x)); } static Fizz FizzSwitch(Fizz x, Fizz y) { final Fizz z = x; z.x = 6; return z; } } What is the result?

  1. true true

  2. false true

  3. true false

  4. false false

  5. Compilation fails.

  6. An exception is thrown at runtime.


Correct Option: A

Given: class Sixties { public static void main(String[] args) { int x = 5; int y = 7; System.out.print(((y * 2) % x)); System.out.print(" " + (y % x)); } } What is the result?

  1. 1 1

  2. 1 2

  3. 2 1

  4. 2 2

  5. 4 1

  6. 4 2


Correct Option: F

Given: public class MyOuter { public static class MyInner { public static void foo() { } } } Which, if placed in a class other than MyOuter or MyInner, instantiates an instance of the nested class?

  1. MyOuter.MyInner m = new MyOuter.MyInner();

  2. MyOuter.MyInner mi = new MyInner();

  3. MyOuter m = new MyOuter();

  4. MyInner mi = new MyOuter.MyInner();


Correct Option: A

public static void main(String[] args) { Queue q = new LinkedList(); q.add("Veronica"); q.add("Wallace"); q.add("Duncan"); showAll(q); } public static void showAll(Queue q) { q.add(new Integer(42)); while (!q.isEmpty()) System.out.print(q.remove() + " "); }

  1. Veronica Wallace Duncan

  2. Veronica Wallace Duncan 42

  3. Duncan Wallace Veronica

  4. 42 Duncan Wallace Veronica

  5. Compilation fails

  6. An exception occurs at runtime.


Correct Option: B

Properties meant for protecting a field in a class?

  1. True

  2. False


Correct Option: A

You can not change fields internal implementation over time?

  1. True

  2. False


Correct Option: B

We achieve Encapsulating Type State with Properties?

  1. True

  2. False


Correct Option: A
- Hide questions