ANSWER KEY (9) - 67 Que

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Chapter 9 Working with Array and String

Unit Test 2018 (Std. 12th E.M.)


STUDENT’S NAME : ____________________________________DIV._________ ROLL NO.: ______

Textbook Exercise

(1) Which of the following refer to the starting index value in arrays?
(A) 0 (B) 1 (C) Null (D) All of these
(2) What is the size of second dimension in an array sales [5] [12]?
(A) 5 (B) 12 (C) 60 (D) 10
(3) What will expression sales.length return for an array sales [5] [12]?
(A) 5 (B) 12 (C) 60 (D) 120
(4) When an array sales [5] [12] is declared without specifying initial values, what is the initial
value of sale [0] [0] ?
(A) 0 (B) default value (C) compilation error (D) 60
(5) What does ‘length’ refer to for an object of String class?
(A) attribute (B) method (C) class variable (D) class name
(6) If ‘str’ is the object of String class and its content is “Thank GOD”, then what is the value
of str.length()?
(A) 9 (B) 10 (C) 8 (D) 11
(7) What type of value is returned when we use get method of Calendar class with constant
DAY_OF_WEEK as an argument?
(A) int (B) char (C) string (D) boolean
12 (General) | March – 2015
(8) What is useful when same operations are to be performed on various elements of the
similar type in Java?
(A) Array (B) String (C) if.....then (D) while
(9) In Java which method is used to fill the whole or partial array with specified value?
(A) fill (B) sort (C) set (D) insert
(10) To make a string object which of the following constructers is used to create a string
object using 1-D ary argument starting at ary [start] with len number of characters ?
(A) String (char ar[], int start, int len) (B) String (int start, int length)
(C) String (int length, int start) (D) String (char ary[], int len)
(11) Which of the methods of string class returns an array of characters as bytes from invoking
string in Java?
(A) int length() (B) byte [ ] get bytes [ ]
(C) int bytes [ ] (D) get bytes [ ]
(12) What type of value is returned when we use get method of calendar class with constant
DAY_OF_WEEK as an argument in Java?
(A) int (B) char (C) string (D) boolean
(13) In Java, by using which sign 1-D array is initialized to separate values of data elements in
braces { } ?
(A) . (Full stop) (B) ; (Colon) (C) ; (Semi colon) (D) , (Comma)
(14) In Java, if ‘str’ is the object of string class and its content is ‘Thank God”, then what is the
value of str.length() ?
(A) 9 (B) 10 (C) 8 (D) 11

Page 1
(15) In Java, how can be array elements accessed using index for each dimension in?
(A) [ ] (B) ( ) (C) { } (D) < >
(16) In Java by using which of the following methods of comparing string returns ‘>0’ integer if
invoking string is greater than ?
(A) boolean equals (string str) (B) boolean compare to (string str)
(C) int compare to (string str) (D) int compare to ignore (string str)
(17) In Java array what is the process of making an object used to manage list of items?
(A) Declare an array object (B) Create an array object
(C) Both (A) and (B) (D) Define Object Method
12 (Science) | March – 2015
(18) Java supports two types of strings that are handled by two classes. Which are they?
(A) String, Buffer String (B) String, String Buffer
(C) String, String Literals (D) String, Buffer
(19) Which constructor can be used without arguments to create a string object with no
character?
(A) String ( ) (B) String { } (C) String < > (D) String [ ]
(20) Which of the following tasks are provided by string class?
(A) Appending string. (B) Extracting part of string.
(C) Splitting string into sub string (D) All of these
(21) Which of the following method returns number of characters in invoking string?
(A) int count() (B) int lencount() (C) int length() (D) int len ()
(22) Which of the following method is used to return a string converted to lower case?
(A) String to Lower Case () (B) String To Lower ()
(C) String () (D) String Lower ()
(23) Which of the following method is used to return a string after appending ‘str’ with the
invoking string ?
(A) String Append() (B) String concat (string str)
(C) String con Append () (D) String Append (string)
(24) Which class encapsulate both date and time and represent the value using milli-seconds
precision ?
(A) Preci class (B) Sec class (C) Date class (D) Time class
(25) Which of the following method is used to construct date object using current system time ?
(A) System() (B) SystemDate() (C) date() (D) Date()
(26) 1-D array is initialized using comma separated values of data elements using which
brackets?
(A) ( ) (B) < > (C) [ ] (D) { }
(27) Sort () and Fill () methods be used in Java by ..... class.
(A) java.util.Arrays (B) util.java.Arrays
(C) Java.Array.util (D) java.arrays.utils
(28) Which type of arrays are used to store tabular data in the form of rows and columns?
(A) 1-D (B) 2-D (C) 3-D (D) All of these
(29) If user wants to store 15 integer values through arrays, then which of the following is used?
(A) int m3 = new int [5] [3] (B) int m2 = new [5] [3]
(C) int m1 = new [15] [15] (D) int m4 = m4 int [2] [3]
(30) If ‘str’ is the object of string class and its content is “INDIAN FLAG”; then what is the value
of str.length()?
(A) 11 (B) 8 (C) 10 (D) 9

Page 2
(31) Which constant is used to display year of calendar?
(A) CAL (B) YEAR CAL (C) YEAR (D) MONTH
(32) Which constant is used to display Hour in 12-hour notation?
(A) 12 HOUR (B) HOUR 12 (C) Hour_of_day (D) HOUR
(33) Which constant is used to display Day number in the year?
(A) DAY_OF_YEAR (B) YEAR_DAY (C) YEAR (D) DAY_YEAR
(34) Vector is used to represent ..... dimensional data structure.
(A) 1 (B) 2 (C) 3 (D) 4
(35) What is useful to represent vector, matrix and other multi-dimensional data?
(A) String (B) Arrays (C) Char (D) Integer
(36) if int mark[ ]={70, 90, 20} is defined, then what will be value of marks[2] ?
(A) 20 (B) Error (C) 70 (D) 90
(37) The array variable starts its index value with what?
(A) Null (B) 2 (C) 1 (D) 0

12 (General) | March – 2016


(38) What is a variable representing a collection of homogeneous types of elements known in
Java?
(A) String (B) Array (C) Input (D) Element
(39) Which of the following refers to the starting index value in arrays in Java?
(A) 3 (B) 2 (C) 1 (D) 0
(40) Which type of method is used to sort entire or part of array in Java?
(A) sort() (B) fill() (C) show() (D) search()
(41) Which syntax is used to declare 1-dimensinal array?
(A) <datatype> <arrayname> [ ]; (B) <datatype> [ ] <arrayname>;
(C) (A) or (B) (D) <arrayname> [ ] <datatype>;
(42) Which property is used with only array name returns the size of its first dimension in
Java?
(A) size (B) width (C) length (D) byte
(43) In Java, String literals, a sequence of characters is enclosed between which sign?
(A) ‘ ’ (Single quote) (B) “ ” (Double quotes)
(C) < > (D) /* ..... */
(44) In Java, from the following which string methods are provided by string class?
(A) To compare strings (B) Combining strings, converting strings
(C) To find length of string (D) All of these
(45) Which string method returns number of characters in invoking string in Java?
(A) int length() (B) int byte()
(C) int getByte() (D) int getlength()
(46) Java library provides Date class in which package?
(A) java.lang (B) java.io (C) java.util (D) java.date
(47) Which constant defined for month of calendar of calendar class in Java?
(A) month (B) MONTH (C) DATE (D) YEAR

12 (Science) | March – 2016

(48) In Java, arrays are useful to represent which type of data?


(A) Vector (B) Matrix
(C) Multi - dimensional (D) All of these
Page 3
(49) In Java, what is used to represent 2-D data structure like table of rows and columns?
(A) Scalar (B) Vector (C) Element (D) Matrix
(50) In Java, to declare a 1-D array we use a pair of which brackets after array name of after
datatype?
(A) < > (B) [ ] (C) { } (D) ( )
(51) If ‘str’ is the object of string class and its content is “Hello” then what is the value of
str.length()?
(A) 5 (B) 6 (C) 7 (D) Error
(52) In Java, which of the following method can be used with java.util.Array class?
(A) sort ( ) (B) fill( ) (C) alert( ) (D) Both (A) and (B)
(53) In Java, to search an element in an array, Arrays class provides which method?
(A) Binary search() (B) String search()
(C) Element search() (D) Line Indsearch()
(54) In Java, 2-D array can be declared in which of the following correct way?
(A) int marks () () = new int [5] [3] (B) int marks {} {} = new int [5] [3]
(C) int marks [] [] = new int [5] [3] (D) int marks <> <> = new int [5] [3]
(55) Java supports two types of strings that are handled by which of the following class or
classes?
(A) String class (B) String Buffer class
(C) Both (A) and (B) (D) String Constroctor class
(56) In Java, who creates a string object with its initial value using ary argument?
(A) String (ary [objet] [ ]) (B) String (char ary [ ])
(C) String (ary [ ], int len) (D) String (ary ( ))
(57) In Java, characters are stored using how many bytes?
(A) 16 bytes (B) 8 bytes (C) 4 bytes (D) 2 bytes
(58) Which are the methods provided by String class in Java?
(A) To compare strings (B) Find length of strings
(C) Combining strings (D) All of these
(59) In Java which string class method returns true if invoking string is same as str?
(A) int equals (string boolean) (B) boolean (Ignore case str)
(C) boolean equals (string str) (D) boolean (string)
(60) In Java, which string class method returns a string after appending str with the invoking
string?
(A) String combine (str) (B) String concate (string str)
(C) String add (str) (D) String join (str)
(61) Java library also provides date class in which of the following package?
(A) java.attr (B) java.lang (C) java.expr (D) java.util
(62) In Java, which method of date class constructs date object using current system time?
(A) getTime() (B) getDate() (C) Date() (D) DateTime()
(63) In Java, which method of date class sets new date and time of an object using elapsed
time?
(A) short getTime() (B) void SetTime (long elapsed time)
(C) void SetDate (Date, Time) (D) setDate()
(64) In Java, which constant of calendar class displays day of calendar month?
(A) DATE (B) DAY (date) (C) month (D) MONTH (date)
(65) In Java, what are the values used for AM_PM constant of calendar class?
(A) 1 for AM, 12 for PM (B) 1 for AM, 0 for PM
(C) 1 for AM, 2 for PM (D) 0 for AM, 1 for PM
Page 4
(66) In Java, which constant of calendar class displays Hours in 12-hour notation?
(A) H_M_S (B) HOUR (C) HOUR_MINUTE (D) HOUR_OF_DAT
(67) In Java, by how many ways we can create an array object?
(A) Infinite (B) 1 (C) 2 (D) 3

Page 5

You might also like