java 2012 paper5
DESCRIPTION
Mock for Exams YCMOUTRANSCRIPT
[30] Which exception may be thrown if the given code is executed giving 2 integer runtime argumentsclass sample{public static void main(String args[]){try { int a=Integer.parseInt(args[0]); int b=Integer.parseInt(args[1]); int c = a + b;System.out.println("Sum is "+c); } catch(ArithmeticException ae) { System.out.println("Arithmetic Exception "+ae.getMessage()); } catch(NumberFormatException ne) { System.out.println("Number Format Exception "+ne.getMessage()); } catch(Exception e) { System.out.println("Exception "+e); }}} Choice a ArithmeticException Choice b NumberFormatException Choice c Exception Choice d None of the above[29] In Java when a compile-time error occurs, then which file is NOT created Choice a source Choice b .java Choice c .class Choice d .exe [28] Which of the following is a run-time error Choice a Missing semicolons
Choice b Dividing an integer by zero Choice c Use of undeclared variables Choice d Missing of brackets[27] In Multithreaded programming, what is the constant numeric value used for setting lowest priority for Threads Choice a 1 Choice b 5 Choice c 4 Choice d 10[26] To create a package what is the first statement included? Choice a import java.aw+.*; Choice b package Choice c public Choice d class [25] What does the following import statement actually mean import java.awt.*; Choice a import awt class from the java package Choice b Import all variables from awt class Choice c Import all the classes from the awt package contained in the java package Choice d Import all the classes from the java package [24] The following statements create what type of inheritance if class B and class C are Base classesclass A extends B extends C
{……………} Choice a Single Inheritance Choice b Multilevel Inheritance Choice c Multiple Inheritance Choice d Hierarchical Inheritance[23] Java does not support Multiple Inheritance. What is an alternative approach provided to implement this Choice a Packages Choice b Interfaces Choice c Collections Choice d Wrapper classes [22] Which of the following is possible using Vector class Choice a It is used to store objects Choice b It can store objects that may vary in size Choice c It is possible to add & delete Choice d All of Three[21] The method insert() is a method used with Choice a Arrays Choice b Strings Choice c StringBuffers
Choice d Vectors[20] What is the error in the following class definitionabstract class sample{abstract calc(int a) { }} Choice a class header is not defined properly Choice b constructor is not defined Choice c method calc is not defined properly Choice d No error[19] What is valid for static methods Choice a They can only call other static methods. Choice b They can only access static data. Choice c They cannot refer to this or super Choice d All of the above[18] Which of the following keywords cannot be used to control access to a class member Choice a interface Choice b abstract Choice c public Choice d protected [17] Identify line numbers where logical errors occur in the following code so that factorial of 5 is calculated.1 class factorial2 {3 public static void main(String args[])4 {
5 int n=0,fact=0;6 for(int n=0;n>=1;n--)7 fact=fact*1;8 System.out.println(“Factorial of 5 is ”+fact);9 }10 } Choice a lines 5,6 Choice b lines 6 Choice c lines 7 Choice d lines 5,6,7 [16] Which of the following portion specified in the for loop is compulsary Choice a initialization Choice b test condition Choice c increment Choice d All of the above [15] Consider the following program code. state the output from itclass ifif{public static void main(String args[]){int x=3, y=1,z=5;if(x>y){if (z<=y){System.out.println(“y is greater than z”);}else{System.out.println(“z is greater than y”);}System.out.println(“x is greater than y”);}else
{if(y>z){System.out.println(“y is greater than z”);}}}} Choice a z is greater than yx is greater than y Choice b y is greater than zx is greater than y Choice c x is greater than yx is greater than z Choice d x is greater than yz is greater than y [14] What line numbers will cause an error when you compile this code1 class iftest2 {3 public static void main(String args[])4 {5 int i=2;6 if(i=2) {7 System.out.println(“Correct”); }8 else9 System.out.println(“Incorrect”); }10 }11 } Choice a 5,9,10 Choice b 6,9 Choice c 6 Choice d 9,10[13] Which of the following is True with respect to branching statements if & switch Choice a
every if statement can be written using switch Choice b every switch statement must have a default case Choice c every case must end with a break statement Choice d every case label follows with a(:) colon [12] 4. What will be the output of the following code segmentint m = 100;int n =103;while(++m<=--n);{System.out.print(m);} Choice a 102 Choice b 101 Choice c 103 Choice d 100[11] What is the value of the expression Math.floor(1.567) Choice a 1.6 Choice b 1 Choice c 2 Choice d 1.5[10] Which of the following operators have lowest precedence Choice a unary operators Choice b binary operators Choice c bitwise operators
Choice d logical operators[9] Which of the following is NOT one of the valid escape sequence available for use in Java Choice a \b Choice b \n Choice c \m Choice d \t[8] What is the process of assigning a smaller type to a larger one with respect to type conversion Choice a casting Choice b Promotion Choice c narrowing Choice d implicit [7] What will be the output of the following code, if executed with command line arguments as follows java cmdline Java is wonderfulclass cmdline{public static void main(String args[]){for(int i=1;i<args.length;i++){System.out.print(args[i]);if(i!=args.length)System.out.print(“ “);}System.out.println();}} Choice a Java
Choice b Java is Choice c is wonderful Choice d cmdline Java is wonderful[6] Which of the following is essential part of a Java Program Choice a Packet statement Choice b Import statement Choice c Class definitions Choice d Main method class[5] Which of the following is NOT a valid documentation comment used in Java Choice a // Choice b \\ Choice c /* */ Choice d /** */[4] What was Java originally called as Choice a Object C Choice b Object Basic Choice c Oak Choice d Pascal [3] Which of the following feature in C is NOT included in Java Choice a Break statement Choice b Continue statement
Choice c Pointer type Choice d Primitive data types[2] OOP treats what as a critical element in program development and does not allow it to flow freely around the system. Choice a Procedures Choice b Action Choice c Data Choice d Method [1] In OOP process by which objects of one class acquire the properties of objects of another class is Choice a Inheritance Choice b Polymorphism Choice c Encapsulation Choice d Abstraction