Tag: programming languages

Questions Related to programming languages

  1. Class A 'is-a' Class B

  2. Class B 'is-a' Class A

  3. Class A 'has-a' Class B

  4. Class B 'has-a' Class A


Correct Option: B

Match the mobile development platforms with programming languages a. Android i. Java b. Blackberry ii.C c. iPhone iii. Java (RIM APIs) d. BREW iv. Objective C

  1. a-i,b-iii,c-iv,d-ii

  2. a-ii,b-i,c-iv,d-iii

  3. a-iii,b-i,c-ii,d-iv

  4. a-i,b-iv-c-ii,d-iii


Correct Option: A

import java.io.*; class Master { String doFileWork() throws FileNotFoundException { return "a"; } } class Slave extends Master { public static void main(String[] args) { String s = null; try { s = new Slave().doFileStuff(); } catch ( Exception x) { s = "b"; } System.out.println(s); } //insert a codeline } Choose the correct answers :

  1. String doFileWork() { return "b"; }

  2. String doFileWork() throws IOException ( return "b"; }

  3. String doFileWork(int x) throws IOException { return "b"; }

  4. String doFileWork() throws FileNotFoundException { return "b"; }

  5. String doFileWork() throws NumberFormatException { return "b"; }

  6. String doFileWork() throws NumberFormatException, FileNotFoundException { return "b"; }


Correct Option: A,D,E,F

class Demo { public static void main(String[] args) { String s = "- " ; try { doMath(args[0]); s += "t "; // line 6 } finally { System.out.println(s += "f "); } } public static void doMath(String a) { int y = 7 / Integer.parseInt(a); } } At commandline if the input is java Demo What will be output?

  1. -f and java.ArrayIndexOutOfBoundsException

  2. -f

  3. ArrayIndexOutOfBoundsException

  4. None of these.


Correct Option: A

class Demo { public static void main(String [] args) { int x = 0; // insert code here do { } while (x++ < y); System.out.println(x); } } Which, inserted at line 4, produces the output 12?

  1. int y = x;

  2. int y = 10;

  3. int y = 11;

  4. None of the above will allow compilation to succeed.

  5. int y = 12;

  6. int y = 13;


Correct Option: C