java paper mock 2

Upload: kaushik-gowda

Post on 02-Mar-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/26/2019 Java Paper Mock 2

    1/11

    [30] Which exception may be thrown if the given code is executed giving 2 integer runtime

    arguments

    class sample{

    public static void main(tring args[]!

    {try

    {

    int a"#nteger$parse#nt(args[0]!% int b"#nteger$parse#nt(args[&]!%

    int c " a ' b%

    ystem$out$println(um is 'c!%

    ) catch(*rithmetic+xception ae!

    { ystem$out$println(*rithmetic +xception 'ae$get,essage(!!% )

    catch(-umber.ormat+xception ne!

    { ystem$out$println(-umber .ormat +xception 'ne$get,essage(!!% ) catch(+xception e!

    { ystem$out$println(+xception 'e!% ))

    )

    /hoice a

    *rithmetic+xception

    /hoice b

    -umber.ormat+xception

    /hoice c

    +xception/hoice d

    -one of the above

    [2] #n 1ava what is a condition that is caused by a runtime error in the program

    /hoice a

    validity

    /hoice b

    exception

    /hoice c

    error

    /hoice d

    action

    [24] Which of the following is a runtime error

    /hoice a

  • 7/26/2019 Java Paper Mock 2

    2/11

    ,issing semicolons

    /hoice b

    5ividing an integer by 6ero

    /hoice c

    7se of undeclared variables/hoice d

    ,issing of brac8ets

    [29] #n ,ultithreaded programming which method is used to return the threads to runnable state

    from the wait state

    /hoice a

    notify(!

    /hoice b

    resume(!/hoice c

    start(!

    /hoice d

    :unnable(!

    [2;] What classes does the 1ava system pac8age ectors hash tables random numbers date etc

    /hoice c

    /lasses for #nput?@utput support

    /hoice d

    /lasses for implementing graphical user interface

    [2A] =he following statements create what type of inheritance if class B and class / are Base

    classesclass * extends B extends /

    {

    CCCCC

    )

    /hoice a

    ingle #nheritance

    /hoice b

    ,ultilevel #nheritance

  • 7/26/2019 Java Paper Mock 2

    3/11

    /hoice c

    ,ultiple #nheritance

    /hoice d

    Dierarchical #nheritance

    [23] What can interfaces containE

    /hoice a

    ,ethods

    /hoice b

    >ariables

    /hoice c

    classes

    /hoice d

    Both & F 2

    5ate 29 1un 20&2

    [22] What value is returned by the compare=o(! tring method if the 2 strings

    compared are eGual

    /hoicea

    0

    /hoice

    b

    &

    /hoicec

    =:7+

    /hoice

    d

    &

    [2&] What will be displayed as output if & contains word 1ava with method &$index@f(HaH!

    /hoice a

    A

    /hoice b

    2

    /hoice c

    &

    /hoice d

    3

    [20] =he concept of inheritance is implemented in 1ava by

  • 7/26/2019 Java Paper Mock 2

    4/11

    /hoice a

    creating more than one class

    /hoice b

    extending two or more classes

    /hoice cextending one class and implementing one or more interfaces

    /hoice d

    importing classes from pac8ages

    [&] What is valid for static methods

    /hoice a

    =hey can only call other static methods$

    /hoice b

    =hey can only access static data$

    /hoice c

    =hey cannot refer to this or super

    /hoice d

    *ll of the above

    [&4] *n expression using operators FF and II used to combine two or more relational statement

    is called

    /hoice a

    combined expression

    /hoice brelational expression

    /hoice c

    logical expression

    /hoice d

    boolean expression

    [&9] What will be the output of the following code segmentint r"&00%

    while(true!

    {if(rJ&0!

    brea8%

    r"r&0%)

    ystem$out$print(Kr is K'r!%

    /hoice a

    r is 0

  • 7/26/2019 Java Paper Mock 2

    5/11

    /hoice b

    r is &0

    /hoice c

    r is &00

    /hoice dr is &0

    [&;] Which of the following is -@= one of the looping constructs available in 1ava

    /hoice a

    switch

    /hoice b

    while

    /hoice c

    do

    /hoice d

    for

    [&L] /onsider the following program code$ state the output from it

    class ifif

    {

    public static void main(tring args[]!

    {

    int x"3 y"&6"L%

    if(xMy!

    {if (6J"y!

    {

    ystem$out$println(Ky is greater than 6N!%

    )

    else

    {

    ystem$out$println(K6 is greater than yN!%

    )

    ystem$out$println(Kx is greater than yN!%

    )

    else

    {

    if(yM6!

    {

    ystem$out$println(Ky is greater than 6N!%

    )

  • 7/26/2019 Java Paper Mock 2

    6/11

    )

    )

    )

    /hoice a

    6 is greater than yx is greater than y

    /hoice b

    y is greater than 6

    x is greater than y

    /hoice c

    x is greater than y

    x is greater than 6

    /hoice d

    x is greater than y

    [&A] What line numbers will cause an error when you compile this code

    & class ch8num

    2 {3 public static void main(tring args[]!

    A {

    L int n"3%

    ; switch(n!%9 {

    4 case 0 O ystem$out$print(K-o is 0N!%

    case & O ystem$out$print(K-o is &N!%&0 case 2 O ystem$out$print(K-o is 2N!%

    && case 3 O ystem$out$print(K-o is 3N!%

    &2 case 3 O ystem$out$print(K@ther -umberN!%brea8%&3 ) ) )

    /hoice a

    Pines 394&0&&

    /hoice b

    Pines ;4&0&&&2

    /hoice c

    Pines 9&0&&/hoice d

    Pines &&&2

    [&3] Which of the following statements do not fall in selection statement category

    /hoice a

  • 7/26/2019 Java Paper Mock 2

    7/11

    if statement

    /hoice b

    switch statement

    /hoice c

    conditional operator statement/hoice d

    for construct statement

    5ate 29 1un 20&2

    [&2] What is the output of the following program code

    class chec8{

    public static void main(tring args[]!

    {boolean b"true%

    ystem$out$println(.alse!%

    if(Qb! return%ystem$out$println(=rue!%

    return%

    )

    )

    /hoice

    a

    =rue

    /hoiceb

    .alse

    /hoice

    c

    .alse

    =rue

    /hoice

    d

    +rror

    [&&] What will be the value of b if a"2 and given the expression b"a''%

    /hoice a

    0

    /hoice b&

    /hoice c

    2

    /hoice d

    3

    [&0] What type of value will the expression (aRb! return where a"&0 and b"9$

  • 7/26/2019 Java Paper Mock 2

    8/11

    /hoice a

    9

    /hoice b

    &

    /hoice cint

    /hoice d

    float

    [] Which of the following are #nteger types in 1ava

    /hoice a

    Byte

    /hoice bPong

    /hoice c

    hort

    /hoice d

    *ll of the options &23

    [4] Which of the following is -@= a valid assignment statement

    /hoice a

    a"b"c"0%

    /hoice b

    a"HaH

    /hoice c

    0"b%

    /hoice d

    c"92$2L

    [9] What will be the output of the following code if executed with command line arguments as

    follows

  • 7/26/2019 Java Paper Mock 2

    9/11

    if(iQ"args$length!

    ystem$out$print(K K!%

    )ystem$out$println(!%

    )

    )/hoice a

    1ava

    /hoice b

    1ava is

    /hoice c

    is wonderful

    /hoice d

    cmdline 1ava is wonderful

    [;] Which of the following is valid rule to create 1ava #dentifier names

    /hoice a

    #t can contain digits alphabets dollar symbol and underscore

    /hoice b

    #t cannot start with a underscore

    /hoice c

    #t cannot contain uppercase letter

    /hoice d

    #t can start with a digit

    [L] Which of the following is -@= one of the

  • 7/26/2019 Java Paper Mock 2

    10/11

    /hoice c

    #t is networ8 application to run applets

    /hoice d

    #t is program that can edit applets

    :eturn

    [3] Which of the following /'' feature is -@= included in 1ava

    /hoice a

    ,ultilevel inheritance

    /hoice b

    #nner classes

    /hoice c

    ,ultithreading

    /hoice d

    @perator overloading

    [2] #n @@S approach programs are divided into

    /hoice a

    @b

  • 7/26/2019 Java Paper Mock 2

    11/11