MCQs CH NO. 8, 9 & 10: FOR STUDENTS OF GUJ. BOARD XII (WITH CORRECT OPTIONS HIGHLIGHTED.)

CHAPTER - 10: Exception Handling in Java
1)            It is usually understood that a compiled program is error free and will always …………………… successfully.
(a)  complete                                                                                (b)  execute
(c)  perform                                                                                   (d)  accomplish
2)            In few cases a compiled program can ………………………………… while it its executing.
(a)  terminate                                                                               (b)  finish
(c)  dismiss                                                                                     (d)  discharge
3)            An exception usually signals an …………………………………
(a)  Exception                                                                                (b)  inaccuracy
(c)  error                                                                                          (d)  e-fault
4)            Although exceptions occur infrequently, one has to be careful in handing such cases while writing the …………………………………
(a)  program                                                                                  (b)  message
(c)  data                                                                                           (d)  code
5)            ………………………………… handling allows a program to continue executing as if no problem had been encountered or it may notify the user of the problem before terminating in an uncontrolled manner.
(a)  Data                                                                                          (b)  Program
(c)  Error                                                                                          (d)  Exception
6)            Error can be broadly classified into………………………………… categories.
(a)  four                                                                                           (b)  three
(c)  two                                                                                            (d)  five
7)            …………………………………is type of error produced in java programs.
(a)  Compile-time errors                                                           (b)  Run-time errors
(c)  Both (a) and (b)                                                                    (d)  None of these
8)            A ………………………………… is used to convert source code into object code.
(a)  compiler                                                                                 (b)  interpreter
(c)  translator                                                                                (d)  decoder
9)            If there is a syntax error in the program, a compilation error is displayed and………………………………… file is not created.
(a)  .source                                                                                     (b)  .dat
(c)  .class                                                                                         (d)  .obj
10)            The array “………………………………… citylist [ ] = {“Ahmedabad”, “Baroda”, “Rajkot”, “Surat”};” contains name of four different cities.
(a)  String                                                                                        (b)  int
(c)  long                                                                                           (d)  boolean
11)            An attempt to access the array element with an index value that is outside the range of array uses………………………………… exception class.
(a)  ArrayIndexOutOfBoundsException                             (b)  ArithmeticException
(c)  FileNotFoundException                                                    (d)  All of these
12)            An attempt to divide any number be 0 uses ………………………………… exception class.
(a)  ArrayIndexOutOfBoundsException                             (b)  ArithmeticException
(c)  FileNotFoundException                                                    (d)  All of these



13)            An attempt to access a non-existing file uses ………………………………… exception class.
(a)  ArrayIndexOutOfBoundsException                             (b)  ArithmeticException
(c)  FileNotFoundException                                                   (d)  All of these
14)            An attempt to use null in a case where an object is required uses………………………………… exception class.
(a)  PrinterIOException                                                             (b)  NullPointeException
(c)  NumberFormatException                                                (d)  None of these
15)            An attempt to convert string to a number type uses………………………………….exception class.
(a)  PrinterIOException                                                             (b)  NullPointeException
(c)  NumberFormatException                                                (d)  None of these
16)            An I/O error has occurred while printing uses ………………………………… exception class.
(a)  PrinterIOException                                                            (b)  NullPointeException
(c)  NumberFormatException                                                (d)  None of these
17)            What is the full form of JVM ?
(a)  Java Virtual Mechanism                                                    (b)  Java Virtual Method
(c)  Java Virtual Machine                                                         (d)  Java Virtual Manner
18)            Java uses keywords like…………………………………to write an exception handler.
(a)  try                                                                                              (b)  catch
(c)  finally                                                                                        (d)  all of these
19)            A…………………………………contains the code that may give rise to one or more exceptions.
(a)  try block                                                                                  (b)  catch block
(c)  finally block                                                                            (d)  all of these
20)            A ………………………………… contains the code that is intended to handle exceptions of a particular type that were created in the associated try block.
(a)  try block                                                                                  (b)  catch block
(c)  finally block                                                                            (d)  all of these
21)            A…………………………………is always executed before the program ends, regarding of whether any exceptions are generated in the try block or not.
(a)  try block                                                                                  (b)  catch block
(c)  finally block                                                                           (d)  all of these
22)            ………………………………… contains the code that is to be created to handle an exception.
(a)  try block                                                                                  (b)  catch block
(c)  finally block                                                                            (d)  all of these
23)            A catch block consists of the keyword catch followed by a single…………………………………
(a)  operator                                                                                  (b)  method
(c)  block                                                                                         (d)  parameter
24)            The  catch block contains a……………………… to object “eobj”which is created and thrown by the try block.
(a)  space                                                                                        (b)  cell
(c)  memory                                                                                   (d)  reference
25)            There is a provision in java to support ………………………………… exceptions.
(a)  various                                                                                     (b)  single
(c)  multiple                                                                                  (d)  some
26)            The ………………………………… catch block, must be the last block when there are multiple catch blocks.
(a)  first                                                                                            (b)  second
(c)  third                                                                                          (d)  default
27)            The ………………………………… is generally used to clean up to end of executing a try block.
(a)  try block                                                                                  (b)  catch block
(c)  finally block                                                                           (d)  all of these
28)            if a particular file has to be uploaded to a remote computer, another exception mayo occur if the computer is not connected to the …………………………………
(a)  computer                                                                                (b)  network
(c)  internet                                                                                   (d)  system
29)            The object that one throws, must be of type java.lang. ……………………… otherwise a compile error occurs.
(a)  Throwable                                                                              (b)  Throws
(c)  throw                                                                                        (d)  throws
30)            A ………………………………… clause can be used in a method declaration or constructor declaration to inform that the code within the constructor or method may throw an Exception.
(a)  Throwable                                                                              (b)  Throws
(c)  throw                                                                                        (d)  throws
31)            When a ………………………………… or a method that can throw exceptions is written to its caller, it is useful to document that fact.
(a)  constructor                                                                            (b)  variable
(c)  operator                                                                                  (d)  compiler
32)            A ………………………………… can throw multiple exceptions.
(a)  method                                                                                   (b)  variable
(c)  operator                                                                                  (d)  compiler
33)            ……………………………… allows creating own exception classes according to application-specific exceptions.
(a)  C ++                                                                                           (b)  C
(c)  Java                                                                                           (d)  PHP
34)            Advantage of using exception-handling in java programs is …………………………………
(a)  it allows maintaining normal flow of program. In the absence of exception handling, the flow of program is disturbed.
(b)  it allows writing separate error handling code from the normal code.
(c)  error types can be grouped an differentiated within the program.
(d)  All of these
35)            Which of the following is the correct syntax in a user defined exception ?
(a)  catch(InvalidMarksExceptioneobj)                             (b)  catch(ArithmeticExceptioneobj)
(c)  catch (ArrayIndexOutOfBounds e)                               (d)  all of these
36)            The statement “throw myobject;” …………………………………
(a)  Throws the exception object implicitly                       (b)  Throws the exception object explicitly
(c)  Throws The object implicitly                                            (d)  None of these
37)            The keywords used with exception handling are …………………………………
(a)  generate, handled, conclude                                         (b)  generate, catch, finally
(c)  throw, catch, conclude                                                      (d)  try, catch, finally
38)            When an array is accessed beyond the array size, ………………………………… exception in thrown.
(a)  Array ElementOut Of Limit                                              (b)  Array Index Out  Of Bounds Exception
(c)  Array Index Out Of Bounds                                             (d)  ArrayElementOut Of Bounds
CHAPTER - 9: Working with Array and Strings
39)            An ………………………………… is a variable representing a collection of homogeneous type of elements.
(a)    arrangement                                                                       (b)   array
(c)    assortment                                                                           (d)   group
40)            …………………………………is one dimensional (1-D) data structure that can be used to store list of items like characters, numbers.
(a)    Vector                                                                                    (b)   Path
(c)    Matrix                                                                                     (d)   Route



41)            ………………………is used to represent two dimensional (2-D) data structure like table or rows and columns.
(a)    Vector                                                                                    (b)   Path
(c)    Matrix                                                                                    (d)   Route
42)            Each element is identified by an ………………………………… position associated with array variable .
(a)    index                                                                                      (b)   value
(c)    tabular                                                                                    (d)   element
43)            In Java, …………………………………is an object used to manage list of items.
(a)    array                                                                                       (b)   variable
(c)    matrix                                                                                     (d)   element
44)            Which is the way an array object can be created?
(a)    Using new operator and specifying the size.         (b)   Directly initializing the content of array
(c)    Both (a) and (b)                                                                  (d)   None of these
45)            Instead of declaring individual variables like marks 1, marks2, marks3, marks4, marks5; one can declare array …………………………………
(a)    Marks[5]                                                                               (b)   Mark[5]
(c)    Marks[1-5]                                                                            (d)   All of these
46)            The syntax to declare array is as follows …………………………………
(a)    <data type><array name> [ ];                                      (b)   < data type> [ ] < array name>;
(c)    both (a) and (b)                                                                  (d)   none of these
47)            To refer an element of an array, an index or subscript is used in …………………… after array variable name.
(a)    curly bracket { }                                                                  (b)   square bracket [ ]
(c)    round bracket ( )                                                                (d)   none of these
48)            The array variable marks [5] has an index value from …………………………………
(a)    1 to 5                                                                                       (b)   0 to 4
(c)    0 to 5                                                                                       (d)   1 to 4
49)            Which of the following is correct initialization of 1-D array?
(a)    int marks [ ] = { 90, 70, 77};                                             (b)   int [ ] marks = { 90,70,77};
(c)    int marks = { 90, 70; 77}                                                    (d)   both (a) and (b)
50)            When an array is initialized while creating, it does not need the use of ………………………………… operator.
(a)    New                                                                                        (b)   new
(c)    int                                                                                             (d)   float
51)            Class methods  are declared as ………………………………… and can be referred without any object in a class.
(a)    private                                                                                   (b)   void
(c)    package                                                                                 (d)   static
52)            Methods sort() and fill () are part of ………………………………… class.
(a)    java. Arrays                                                                          (b)   java.util
(c)    java.util.Arrays                                                                   (d)   all of these
53)            Method …………………………………is used to fill or partial array with specified value.
(a)    sort( )                                                                                     (b)   fill ( )
(c)    display ( )                                                                               (d)   order ( )
54)            To search an element in an array, arrays class provides ………………………………… method.
(a)    search ( )                                                                               (b)   find ()
(c)    binary search ( )                                                                 (d)   bin search ( )
55)            In java, 2-D array can be declared using array name and 2 pairs of ………………………………… to specify the size of two dimensions row and column respectively.
(a)    Curly bracket { } { }                                                            (b)   Square bracket [ ] []
(c)    Round bracket ( ) ( )                                                          (d)   None of these
56)            Individual variable elements of an array marks[5] can be accessed as:
(a)    marks [1], marks[2], marks[3], marks[4], marks[5]
(b)   marks [-1], marks[1], marks[2], marks[3], marks[4]
(c)    marks [0], marks[1], marks[2], marks[3], marks[4]
(d)   marks [-1], marks[0], marks[1], marks[2], marks[3]
57)            ………………………………… literals are where a sequence of characters is enclosed between double quotes.
(a)    String                                                                                      (b)   Character
(c)    Numerical                                                                             (d)   None of these
58)            Strings in java are handled by two classes namely ‘String’ and …………………………………
(a)    Strings                                                                                    (b)   Characters
(c)    Buffer                                                                                     (d)   String Buffer
59)            A ………………………………… can be used with array of bytes as an argument.
(a)    method                                                                                 (b)   destructor
(c)    variable                                                                                  (d)   constructor
60)            “strl = = str2” ………………………………… the contents of str1 and str2 and not the objects at str1 and str2.
(a)   equals                                                                                     (b)   matches
(c)   compares                                                                               (d)   relates
61)            Method intcompareTolgnore Case (String str) is same as ………………………………… but case sensitive.
(a)    Equals                                                                                     (b)   IgnoreCase
(c)    equalsIgnoreCase                                                              (d)   compareTo
62)            Method int ………………………………… returns number of characters in invoking string.
(a)    indexAt(int index)                                                             (b)   length ( )
(c)    getBytes( )                                                                            (d)   toUpperCase( )
63)            Method char …………………………………returns character at index position from the invoking string, index considered from 0.
(a)    indexAt (int index)                                                           (b)   length( )
(c)    getBytes( )                                                                            (d)   toUpperCase( )
64)            Method char ………………………………… returns character at index position from the invoking string, index considered from 0.
(a)    IndexAt (int index)                                                           (b)   length( )
(c)    getBytes( )                                                                            (d)   toUpperCase( )
65)            Method ………………………………… constructs data object using current system time.
(a)    Date (long elapsed Time)                                               (b)   Date ()
(c)    toString()                                                                               (d)   getTime( )
66)            Method long ………………………………… returns number of milliseconds since  January 1, 1970 GMT.
(a)    Date (long elapsed Time)                                               (b)   Date ()
(c)    toString()                                                                               (d)   getTime( )
67)            Method void set time (long elapsed Time) sets new date and time of an object using elapsed time.
(a)    setTime (long elapsed Time)                                       (b)   Date()
(c)    toString()                                                                               (d)   getTime()
68)            If ‘a’ is the object of String class and its content is “C IS A LANGUAGE”,  then what is the value of str.length() ?
(a)    14                                                                                             (b)   15
(c)    12                                                                                             (d)   11
69)            What is the full form of GMT?
(a)    Greenwich Median Time                                                (b)   Greenwich Mode Time
(c)    Greenwich Modern Time                                               (d)   Greenwich mean Time



CHAPTER - 8: Exception Handling in Java
70)            When a program contains two or more classes, only one class can contain the ………………………… method.

(a)    Main
(b)   Major
(c)    main ( )
(d)   minor

71)            What is SciTE editor?

(a)    Scintilla based Text Editor
(b)   Scientific based Text Editor
(c)    Sourceful Text Editor
(d)   Syntax Text Editor

72)            For example, class ‘Room’ is a ………………………………… for all rooms with their common properties.

(a)    pattern
(b)   protocol
(c)    template
(d)   model

73)            ………………………………… is defined by methods in a class.

(a)    Behaviour
(b)   Mannerism
(c)    Patterns
(d)   Properties

74)            ………………………………… means creating the object by allocating the memory.

(a)    Instantiation
(b)   Initialization
(c)    Declaration
(d)   Modification

75)            A variable declared using class type can only store a ………………………………… to an object.

(a)    orientation
(b)   position
(c)    reference
(d)   indication

76)            Using ………………………………. keyword, an object can be created.

(a)    int
(b)   float
(c)    new
(d)   real

77)            There is a special portion of memory called the ………………………………… where the objects live.

(a)    Heap
(b)   Pile
(c)    Stack
(d)   All of these

78)            An object can be created of type Room and assign its address to variable r1 as …………………………………

(a)    r1= new Room();
(b)   r1= Room() new;
(c)    r1 = Class Room ();
(d)   none of these

79)            In Java, there is no requirement to do any explicit freeing of …………………………………

(a)    cells
(b)   variables
(c)    memory
(d)    class

80)            An ………………………………… for an object is created by allocating memory to store data for that object.

(a)    instance
(b)   example
(c)    illustration
(d)   none of these

81)            An object that belongs to a ………………………………… is said to be an instance of that class.

(a)    cells
(b)   variables
(c)    memory
(d)   class

82)            Objects can be referred by using ………………………………… operator.

(a)    Colon (:)
(b)   Underscore (_)
(c)    dot (.)
(d)   Angle Bracket *(<)

83)            Referring instance variable or invoking method with null reference will give …………………………………

(a)    example
(b)   error
(c)    mistake
(d)   inaccurate result

84)            ………………………………… variables and class methods can be accessed outside the class.

(a)    Class
(b)   Variables
(c)    Operator
(d)   Method


85)            The ……………………………… definitions in the source code specify the things that are part of the class itself.

(a)    public
(b)   non-static
(c)    static
(d)   private

86)            The word ………………………………… means “many forms”; different forms of methods with same name.

(a)    Declaration
(b)   Instantiation
(c)    Polymorphism
(d)   Inheritance

87)            In java, there can be different methods that have the same but different…………………………………

(a)    variables
(b)   declarations
(c)    programs
(d)   signature

88)            The above feature of java is called …………………………………

(a)    Method Overloading
(b)   Method Offloading
(c)    Variable Overloading
(d)   Program Overloading

89)            …………………………………statement should be added as the first non-comment or non-blank line in the source file.

(a)    Public
(b)   Package
(c)    Protected
(d)   Private

90)            When a file does not have package statement, the classes defined in the file are placed in …………………… package.

(a)    public
(b)   file
(c)    default
(d)   private

91)            ………………………………… keyword is used to allow the access only to sub classes or to share with the methods declared as “friend”.

(a)    Public
(b)   Private
(c)    Protected
(d)   Default

92)            Highest level of protection can be achieved by using “…………………………………” protection level.

(a)    Public
(b)   Private
(c)    Protected
(d)   Default

93)            If the requirement is there that private data has to be used by others, then ………………………………… methods have to be written.

(a)    accessor
(b)   mutator
(c)    Restricted
(d)   Prefixed

94)            If the requirement is there that private data has to be modified by others, then ………………………………… methods have to be written.

(a)    accessor
(b)   mutator
(c)    restricted
(d)   prefixed

95)            Conventionally, naming of accessor and mutator methods is to capitalize the first letter of variable name and then prepend the variable name with the prefixes ………………………………… respectively.

(a)    set and get
(b)   get and setter
(c)    getter and set
(d)   get and set

96)            Object-oriented programming languages provide reusability feature using …………………………………

(a)    polymorphism
(b)   parameters
(c)    inheritance
(d)   all of these

97)            Inheritance models ………………………………… relationship between two classes.

(a)    ‘is-a’
(b)   ‘its-a’
(c)    ‘has-a’
(d)   ‘is-at’


98)            In the same way; child class is also referred to as …………………………………, derived class or extended class.

(a)    Inherited Class
(b)   Parent Class
(c)    Sub Class
(d)   Super class

99)            A sub class is not a subset of ………………………………… in fact, sub class usually contains more information and methods than its super class.

(a)    Inherited Class
(b)   Parent class
(c)    Sub Class
(d)   Super class

100)            In java, to create a sub class, keyword ………………………………… is used in the class definition.

(a)    extends
(b)   int
(c)    float
(d)   create

101)            ………………………………… andaggregation are the construction of classes that incorporate other objects.

(a)    Composition
(b)   Inheritance
(c)    Methods
(d)   Constructors

102)            Composition and Aggregation establish a “…………………………………” relationship between classes.

(a)    Is-a
(b)   has-a
(c)    its-a
(d)   all of these

103)            When a class includes objects of other class, it is also referred to as ………………………………… class.

(a)    fixed
(b)   movable
(c)    container
(d)   none of these

104)            Class variables and methods are defined using ………………………………… keyword.

(a)    private
(b)   protected
(c)    static
(d)   all of these

105)            ………………………………… members of class are visible only within a class where they are defined.

(a)    Public
(b)   Private
(c)    Package
(d)   Protected

106)            ………………………………… members of class are visible only in inherited sub classes.

(a)    Public
(b)   Private
(c)    Package
(d)   Protected

107)            ………………………………… members of class are visible anywhere within a package.

(a)    Public
(b)   Private
(c)    Package
(d)   Protected

108)            ………………………………… members of class are visible everywhere.

(a)    Public
(b)   Private
(c)    Package
(d)   Protected

109)            Which of the following can be said as a method or method name?

(a)    Show
(b)   Library;
(c)    Int I;
(d)   Display ( )

110)            Which of the following is a no-argument constructor?

(a)    Room ( ) { };
(b)   Room { };
(c)    Room (int i) { };
(d)   Room (float f) { };


* * * * *

No comments

Post your comments

Powered by Blogger.