architecture Online Quiz - 20

architecture Online Quiz - 20

20 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

public class Dec26 { public static void main(String[] args) { short a1 = 6; new Dec26().go(a1); new Dec26().go(new Integer(7)); } void go(Short x) { System.out.print("S "); } void go(Long x) { System.out.print("L "); } void go(int x) { System.out.print("i "); } void go(Number n) { System.out.print("N "); } } What is the result?

  1. i L
  2. i N
  3. S L
  4. S N
  5. Compilation fails.
Question 2 Multiple Choice (Single Answer)

import java.util.Scanner; public class ScannerTest { public static void main(String[] args) { Scanner scanner = new Scanner("hello 1 2.00 false"); scanner.useDelimiter(" "); String str = scanner.next(); int anInt = scanner.nextInt(); float aFloat = scanner.nextFloat(); boolean booleanValue = scanner.nextBoolean(); System.out.println(str + ":" + anInt + ":" + aFloat + ":" + booleanValue); } } What is the output?

  1. The program will output 'hello:1:2.0:false'
  2. The program will throw Input Mismatch exception at the run-time
  3. The program will output nothing.
  4. The program will ouput ':1:2.0:false'
Question 3 Multiple Choice (Single Answer)

public class Gen

  1. Compile time Error at line 1
  2. Compile time Error at line 3
  3. Compile time Error at line 4
  4. Compile time Error at line 5
  5. Run Time Error
Question 4 Multiple Choice (Single Answer)

What will be printed out if you attempt to compile and run the following code? int i=9; switch (i) { default: System.out.println("default"); case 0: System.out.println("zero"); break; case 1: System.out.println("one"); case 2: System.out.println("two"); }

  1. default
  2. default, zero
  3. error default clause not defined
  4. no output displayed
Question 5 Multiple Choice (Single Answer)

Which of the following statements are true?

  1. Methods cannot be overridden to be more private
  2. static methods cannot be overloaded
  3. private methods cannot be overloaded
  4. An overloaded method cannot throw exceptions not checked in the base class
Question 6 Multiple Choice (Single Answer)

What will be printed out if this code is run with the following command line? java myprog good morning public class myprog{ public static void main(String argv[]) { System.out.println(argv[2]); } }

  1. myprog
  2. good
  3. morning
  4. Exception raised: "java.lang.ArrayIndexOutOfBoundsException: 2"
Question 7 Multiple Choice (Single Answer)

Which of the following is not keyword or reserved word in Java?

  1. if
  2. then
  3. goto
  4. while
  5. case
Question 8 Multiple Choice (Single Answer)

What will happen if you try to compile and run the following code? public class Q { public static void main(String argv[]){ int anar[]=new int[5]; System.out.println(anar[0]); } }

  1. Error: anar is referenced before it is initialized
  2. null
  3. 0
  4. 5
Question 9 Multiple Choice (Single Answer)

What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current directory? import java.io.*; public class Mine { public static void main(String argv[]){ Mine m=new Mine(); System.out.println(m.amethod()); } public int amethod() { try { FileInputStream dis=new FileInputStream("Hello.txt"); }catch (FileNotFoundException fne) { System.out.println("No such file found"); return -1; }catch(IOException ioe) { } finally{ System.out.println("Doing finally"); } return 0; } }

  1. No such file found
  2. No such file found ,-1
  3. No such file found, Doing finally, -1
  4. 0
Question 10 Multiple Choice (Single Answer)

What will happen if you attempt to compile and run the following code? class Base {} class Sub extends Base {} class Sub2 extends Base {} public class CEx{ public static void main(String argv[]){ Base b=new Base(); Sub s=(Sub) b; } }

  1. Compile and run without error
  2. Compile time Exception
  3. Runtime Exception
  4. None of the above
Question 11 Multiple Choice (Single Answer)

What is the result of the following operation? System.out.println(4 | 3);

  1. 6
  2. 0
  3. 1
  4. 7
Question 12 Multiple Choice (Single Answer)

You need to create a class that will store unique object elements. You do not need to sort these elements but they must be unique. What interface might be most suitable to meet this need?

  1. Set
  2. List
  3. Map
  4. Vector
Question 13 Multiple Choice (Single Answer)

Which of the following statements are true?

  1. At the root of the collection hierarchy is a class called Collection
  2. The collection interface contains a method called enumerator
  3. The interator method returns an instance of the Vector class
  4. The Set interface is designed for unique elements
Question 14 Multiple Choice (Single Answer)

There is a table called Employee having columns are empno, ename , job , deptno,grade and salary. Which of the following is a correct query to change all emp salary with salary<10000 to 1.5 times and grade to ‘Promo’

  1. Update Employee set salary = salary * 1.5 and grade=’Promo’ where salary < 10000;
  2. Update Employee set salary = salary * 1.5, grade=’Promo’ where salary < 10000;
  3. Update table Employee set salary = salary * 1.5, grade=’Promo’ where salary < 10000;
  4. Update table Employee set salary = salary * 1.5 and grade=’Promo’ where salary < 10000;
Question 15 Multiple Choice (Single Answer)

Which of the following is Data Definition Language?

  1. INSERT
  2. CREATE
  3. UPDATE
  4. DELETE
Question 16 Multiple Choice (Single Answer)

Which type of Statement can execute parameterized queries?

  1. PreparedStatement
  2. ParameterizedStatement
  3. ParameterizedStatement and CallableStatement
  4. All kinds of Statements (i.e. which implement a sub interface of Statement)
Question 17 Multiple Choice (Single Answer)

Which type of Statement can execute queries stored on db server?

  1. CallableStatement
  2. ParameterizedStatement
  3. ParameterizedStatement and CallableStatement
  4. All kinds of Statements (i.e. which implement a sub interface of Statement)
Question 18 Multiple Choice (Single Answer)

Which packages contain the JDBC classes?

  1. java.jdbc and javax.jdbc
  2. java.jdbc and java.jdbc.sql
  3. java.sql and javax.sql
  4. java.rdb and javax.rdb
Question 19 Multiple Choice (Single Answer)

Which of the following are true ?

  1. The executeUpdate method returns all the rows that were affected
  2. The executeUpdate method returns the no. of rows that were affected
  3. Depends , as there is more than one version of this method with different return types
  4. None of the above
Question 20 Multiple Choice (Single Answer)

Which of the following is false wrt Transactions ?

  1. A transaction is a set of sql statements
  2. Auto commit to be set off before Transaction
  3. Auto commit to be set off after transaction
  4. Commit permanently records to database all changes waiting with current Connection
  5. Rollback is used in case of any error to undo transaction