STD 12 Chapter 9 Working With Array and String Textual Exercise and Previous Years Board Papers
The document discusses questions related to arrays and strings in Java. It contains 43 multiple choice questions about array declaration and initialization, string methods like length(), compareTo(), concatenation, and Calendar class methods. The questions cover topics like array indexing, multi-dimensional arrays, string comparison and manipulation.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100%(1)100% found this document useful (1 vote)
410 views10 pages
STD 12 Chapter 9 Working With Array and String Textual Exercise and Previous Years Board Papers
The document discusses questions related to arrays and strings in Java. It contains 43 multiple choice questions about array declaration and initialization, string methods like length(), compareTo(), concatenation, and Calendar class methods. The questions cover topics like array indexing, multi-dimensional arrays, string comparison and manipulation.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10
Chapter 9 Weightage:
Working with Array and String
10 marks Previous Years’ Board Paper – Question Bank Textual 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) 10 (4) When an arraysales[5][12] is declared without specifying initial values, what is the initial value of sales[0][0]? (A) 0 (B) default value (C) compilation eror (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
Std. 12 (General) | March – 2020
(8) Which of the following methods returns true if invoking string is same as str? (A) boolean compare to(string str) (B) boolean equals(string str) (C) int compare to(str string) (D) int equals(string str) (9) How many integer values will be stored in the following array? int marks[][]=new int[4][4];? (A) 8 (B) 644 (C) 16 (D) 4 (10) Which of the following methods returns a string after appending str with the invoking string? (A) string to Lower case() (B) string to Upper case() (C) string concat(string str) (D) int length() (11) What is the value of December month in the MONTH constant of calendar class? (A) 12 (B) 1 (C) 11 (D) 0 (12) If calendar is an object of calendar class, then which of the following commands will set the date to 20? (A) calendar.get ( calendar.DATE,20) (B) calendar.set ( calendar.DATE,20) (C) get.calendar ( calendar.DATE,20) (D) set.calendar ( calendar.DATE,20) (13) Which of the following options is not proper for array declaration with initial values? (A) int marks[3] =new marks{90, 70, 77}; (B) int marks[] = {90, 70, 77}; (C) int []marks = {90, 70, 77}; (D) int marks[] = {90, 80,70, 60}; (14) Which of the following constructors creates an object that refers to the literal specified in argument? (A) string ( string literal) (B) string ( char literal) (C) string ( string strobj) (D) string ( char ary [ ] ) (15) Which method of data class sets new date and time of an object using elapsed time? (A) void setTime(long elapsedTime) (B) long getTime() (C) Date(long elapsedTime) (D) Date() (16) Which command is used to assign value 5 to all elements of list array? (A) sort(list, 5) (B) sort(list,1,7,5) (C) fill(list,2,6,5) (D) fill(list, 5) (17) Which kind of variable is a variable representing a collection of homogeneous type of elements? (A) Local (B) Instance (C) Global (D) Array
Compiled by Nuzhat Ibrahim Memon 1
Std. 12 (Science) | March – 2020 (18) Which is a variable in Java representing a collection of homogeneous type of elements? (A) function (B) array (C) for loop (D) while loop (19) Which of the following syntax is used to declare array in Java? (A) <data type> <array name> [ ]; (B) <data type> [ ] <array name>[]; (C) Both (A) and (B) (D) None of the above (20) How many bytes of memory location are occupied by an array ‘b’ of int b[][]=new int[5][3];? (A) 60 (B) 15 (C) 5 (D) 3 (21) What can be considered as a sequence of characters in Java? (A) null value (B) group (C) string (D) object (22) Which of the following statement is true to compare the contents of str1 and str2? (A) str1 != str2 (B) str1 = str2 (C) str1 (=) str2 (D) str1 == str2 (23) For which of the tasks, methods are provides by string class in Java? (A) Compare strings (B) Find length of string (C) Combining strings (D) All of the above (24) Which of the following statement is true to return a string with all characters of str1 converted to lowercase? (A) str1.Tolowercase() (B) str1.toLowerCase() (C) str1.TOLOWERCASE() (D) toLowerCASE() (25) Date class is available in which of the following Java package? (A) java.util package (B) java.Data package (C) java.All package (D) java.Calendar package (26) Which information can be extracted by Calendar class of jaa.util package of java? (A) Year. Month (B) Hour, Minute (C) (A) & (B) both (D) None of the above (27) What does ‘length’ refer to for an object of String class? (A) method (B) attribute (C) class variable (D) class name
Std. 12 (General) | March – 2019
(28) In java, Calendar class is provided into which package? (A) java.Date (B)java.calendar (C)java.year (D) java.util (29)What type of value is returned when we use get method of Calendar class with constant DAY_OF_YEAR as an argument? (A)int (B) Char (C) String (D) boolean (30) Which of the following is not a right statement to declare an array named marks in java? (A) int marks[]=new int[3] (B) int[] marks=new int[3] (C) int marks[3]={50,60,70} (D) int marks[]={10,20,30} (31)In java, which of the following is used to represent a collection of homogeneous type of elements? (A)function (B) array (C) procedure (D) switch (32) In java, initial value of array elements are specified into what brackets ? (A) () (B) { } (C) [ ] (D) <> (13)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 (34) In Java,intcompareto(string str) method returns which value if invoking string is equal to str? (A) 0 (B) >0 (C) <0 (D) -1 (35) Which method of java.util.Arrays class is used to fill the whole or partial array with specified value ? (A) sort() (B) put() (C) print() (D) fill() (36) Which method of Date class of java returns a string representing data and time of invoking object? (A) longgetTime() (B) Date(long elapsedTime) (C) void Time(long elapsedTime) (D) String toString() (37)In Java,which of the following methods of string class returns a string after appending str with the invoking string? (A) charindexAt(int index) (B) byte[] getBytes() (C) String concat (String str) (D) String append(String str)
Compiled by Nuzhat Ibrahim Memon 2
Std. 12 (Science) | March – 2019 (38)Which of the following are useful to represent vector, matrix and other multi-dimensional data? (A) Variable (B) Element (C) Array (D) Tag (39)Which of the following refer to the starting index value in arrays? (A) 0 (B) 1 (C) null (D) All of these (40) If ‘intmarks[]={1,2,3,4,5};’ is defined in java what will be the value of marks[3] ? (A) 3 (B) 2 (C) 4 (D) 5 (41)Which of the following constructor is used for without arguments create a string object with no character? (A) String[] (B) String() (C) String{} (D) String(] (42) Which of the following string class method returns true if invoking string is same as str? (A) Boolean equals(string str) (B) Boolean eq(string str) (C)Boolean Equal(string str) (D) boolean Eq(string str) (43) Which of the following string class method returns number of characters in invoking string? (A) int LENGTH() (B) Int Length() (C) int length() (D) Float int length() (44) Which of the following Date class method constructs Date object using current system time? (A) Date(cur()) (B) Date[date()] (C) Date(long()) (D) Date() (45) Date & Calendar class is provided in which of the following package? (A) java.util (B) java.dc (C) java.class (D) java.dateclass (46) Which of the following constant is defined in calendar class for year of calendar? (A) YYYY (B)YRS (C) YY (D) YEAR (47) What is the size of second dimension in an array gseb[5][3]? (A) 3 (B) 5 (C) 15 (D) 18
Std. 12 (General) | March – 2018
(48) Which type of array is used like table of rows and columns? (A) primitive array (B) 1-D array (C) 2-D array (D) minor array (49) int marks[][]=new int[5][3] How many bytes are used in storage space ? (A)15 (B) 5 (C) 3 (D) 60 (50) Which constructor creates a string object which is same as object specified in argument? (A) String(string literal) (B) String (string strobj) (C) String (char ary[]) (D) string() (51) From the following which method of string class return a string with all characters of invoking string converted to upper case? (A) String touppercase() (B) string tolowercase() (C) byte[] getbytes (D) int length() (52) Date class is in which package in Java ? (A) java.io.class (B) java.lang (C) java.util (D) java.io (53)Which 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 (54) If ‘str’ is the object of string class and its content is “I_Like_Computer”, then what is the value of str.length()? (A) 13 (B) 17 (C) 19 (D) 15 (55)What stands for AM & PM in integer constant of calendar class? (A) 0 & 1 (B) 1& 0 (C)1 & 1 (D) 0 & 0 (56)Which braces Is used in 2 D array using comma separated values of data elements? (A) [] (square bracket) (B) {}(curly bracket) (C) () (simple bracket) (D) <> (angled bracket) (57) Which of the following refer to the starting index value in arrays ? (A) 1 (B)0 [zero] (C) null (D) All the given options
Std. 12 (Science) | March – 2018
(58) In Java, array index value starts from which number? (A) 8 (B) 1 (C) -1 (D) 0
Compiled by Nuzhat Ibrahim Memon 3
(59) In Java, initial value for 1-D array are separated using which symbol? (A) –(dash) (B) ,(comma) (C) :(colon) (D) .(full stop) (60)Which of the following is not a correct way to create and initialize an array named marks? (A) int marks[3]={0,10,20}; (B) int[] marks=new int[3]; (C) int marks[]={0,10,20}; (D) int marks[]=new int[3]; (61) sort and fill() are methods of which of the following java calss? (A) java.util.io (B) java.util.Arrays (C) java.io (D) java.string (62) In the following statement for declaring two-dimensional arry of Java 5 represent what? Intmarks[][]=new int[5][3]; (A) number of bytes (B) number of columns (C) array size (D) number of rows (63) Which constructor creates a string object which is same as object specified in argument? (A) String (string literal) (B) String (string strobj) (C) String (char ary[]) (D) string() (64) In Java ,intcompareTo(String str) method returns which of the following value if invoking string is greater than str? (A) Logical value (B) >0 (C) <0 (D) 0 (65) Which of the followingmethod of java, returns an array of characters as bytes from invoking string? (A) String to byte() (B) char getByte() (C) byte[] getBytes() (D) String concat() (66)In java, which of the following method of Date class returns a string representing date and time of invoking object? (A) DateText() (B) String toString() (C) Date char() (D) Date() (67) In Java which constant of calendar class returns day number within a week? (A) DATE (B) DAY_OF_MONTH (C) DAY_OF_YEAR (D) DAY_OF_WEEK
Std. 12 (General) | March – 2017
(68)Which of the following constructor is used for without arguments create a string object with no character? (A) String(Charary[]) (B) String() (C) String(String strobj) (D) String(str literal) (69) Which operator can be used to concatenate a string in java? (A) = (B) + (C) & (D) * (70)In java, to search an element in an array, array class provides which type of method? (A) fill() (B) binarySearch() (C)sort() (D) remove() (71)Which type of braces is used to initialize data elements in 1-D aray? (A)<> (B) [] (C) {} (D) () (72) If ‘str’ is the object of string class and its content is “Hello”, then what is the value of str.length()? (A) 8 (B) 7 (C) 6 (D) 5 (73) From the following which method of string class return a string with all characters of invoking string converted to upper case? (A) int length() (B) byte[] getbytes() (C) String toUppercase() (D) String concat(string str) (74) We can use various static methods provided by Java using which array class? (A) java.util.Arrays (B) java.io (C) java.lang (D) All of these (75) which method of date class constructs date object using current system time in Java ? (A) Date &Time() (B) Today’s Date() (C) Date() (D) now() (76)What is the size of second dimension in an array sales[5][12]? (A)5 (B) 12 (C) 60 (D) 11 (77) Arrays are useful to represent which type of data in Java? (A) vector (B) matrix (C) multi-dimensional (D) All of these
Std. 12 (General) | March – 2016
(78) What is a variable representing a collection of homogenous types of elements known in Java? (A) String (B) Array (C) Input (D) Element (79) 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 (80) Date library provides Date class in which package? (A) java.lang (B) java.io (C) java.util (D) java.date
Compiled by Nuzhat Ibrahim Memon 4
(81) Which string method returns number of characters in invoking string in java? (A) intlength() (B) intbyte() (C) intgetByte() (D) intgetlength() (82) Which constant defined for month of calendar of calendar class in Java? (A) month (B) MONTH (C) DATE (D) YEAR (83) Which type of method is used to sort entire or part of array in Java? (A) sort() (B) fill() (C) show() (D) search() (84) In java, string literals, a sequence of characters is enclosed between which sign? (A) ‘ ‘(single quote) (B) “ “(double quotes) (C) <> (D) /*….*/ (85)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 (86)Which syntax is used to declare 1-dimensional array? (A) <datatype><arrayname>[]; (B) <datatype>[] <arrayname>; (C) Both (A) and (B) (D) <arrayname>[]<datatype>; (87) Which of the following refer to the starting index value in arrays ? (A) 0 (B) 1 (C) null (D) All of these
Std. 12 (General) | March – 2015
(88) 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 (89) In java, how can be array elements accessed using index for each dimension in? (A) [ ] (B) ( ) (C) { } (D) <> (90) In java, which method is used to fill the whole or partial array with specified value ? (A) sort (B) set (C) insert value (D) fill (91) To make a string object which of the following constructors is used to create a string object using 1-D ary argument starting at ary[start] with len number of character? (A) String(char ary[], int start, int len) (B) String(int start, int length) (C) String(int length, int start) (D) String(char ary[], int len) (92) In Java by using which of the following methods of comparing string returns ‘>0’ integer if invoking string is greater than? (A) Boolean equal(String str) (B)Boolean compare to(String str) (C) int compare to(String str) (D) int compare to ignore(String str) (93) Which of the followingmethod of java, returns an array of characters as bytes from invoking string? (A) int length() (B) byte[] getbytes() (C) int bytes() (D) get bytes[] (94) 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 (95) Which 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 (96) 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 (97) 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)
Compiled by Nuzhat Ibrahim Memon 5
Chapter 9 Weightage: Working with Array and String 10 marks Answer Key - Previous Years’ Board Paper Textual 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) 10 (4) When an arraysales[5][12] is declared without specifying initial values, what is the initial value of sales[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
Std. 12 (General) | March – 2020
(8) Which of the following methods returns true if invoking string is same as str? (A) boolean compare to(string str) (B) boolean equals(string str) (C) int compare to(str string) (D) int equals(string str) (9) How many integer values will be stored in the following array? int marks[][]=new int[4][4];? (A) 8 (B) 644 (C) 16 (D) 4 (10) Which of the following methods returns a string after appending str with the invoking string? (A) string to Lower case() (B) string to Upper case() (C) string concat(string str) (D) int length() (11) What is the value of December month in the MONTH constant of calendar class? (A) 12 (B) 1 (C) 11 (D) 0 (12) If calendar is an object of calendar class, then which of the following commands will set the date to 20? (A) calendar.get ( calendar.DATE,20) (B) calendar.set ( calendar.DATE,20) (C) get.calendar ( calendar.DATE,20) (D) set.calendar ( calendar.DATE,20) (13) Which of the following options is not proper for array declaration with initial values? (A) int marks[3] =new marks{90, 70, 77}; (B) int marks[] = {90, 70, 77}; (C) int []marks = {90, 70, 77}; (D) int marks[] = {90, 80,70, 60}; (14) Which of the following constructors creates an object that refers to the literal specified in argument? (A) string ( string literal) (B) string ( char literal) (C) string ( string strobj) (D) string ( char ary [ ] ) (15) Which method of data class sets new date and time of an object using elapsed time? (A) void setTime(long elapsedTime) (B) long getTime() (C) Date(long elapsedTime) (D) Date() (16) Which command is used to assign value 5 to all elements of list array? (A) sort(list, 5) (B) sort(list,1,7,5) (C) fill(list,2,6,5) (D) fill(list, 5) (17) Which kind of variable is a variable representing a collection of homogeneous type of elements? (A) Local (B) Instance (C) Global (D) Array
Compiled by Nuzhat Ibrahim Memon 6
Std. 12 (Science) | March – 2020 (18) Which is a variable in Java representing a collection of homogeneous type of elements? (A) function (B) array (C) for loop (D) while loop (19) Which of the following syntax is used to declare array in Java? (A) <data type> <array name> [ ]; (B) <data type> [ ] <array name>[]; (C) Both (A) and (B) (D) None of the above (20) How many bytes of memory location are occupied by an array ‘b’ of int b[][]=new int[5][3];? (A) 60 (B) 15 (C) 5 (D) 3 (21) What can be considered as a sequence of characters in Java? (A) null value (B) group (C) string (D) object (22) Which of the following statement is true to compare the contents of str1 and str2? (A) str1 != str2 (B) str1 = str2 (C) str1 (=) str2 (D) str1 == str2 (23) For which of the tasks, methods are provides by string class in Java? (A) Compare strings (B) Find length of string (C) Combining strings (D) All of the above (24) Which of the following statement is true to return a string with all characters of str1 converted to lowercase? (A) str1.Tolowercase() (B) str1.toLowerCase() (C) str1.TOLOWERCASE() (D) toLowerCASE() (25) Date class is available in which of the following Java package? (A) java.util package (B) java.Data package (C) java.All package (D) java.Calendar package (26) Which information can be extracted by Calendar class of jaa.util package of java? (A) Year. Month (B) Hour, Minute (C) (A) & (B) both (D) None of the above (27) What does ‘length’ refer to for an object of String class? (A) method (B) attribute (C) class variable (D) class name
Std. 12 (General) | March – 2019
(28) In java, Calendar class is provided into which package? (A) java.Date (B)java.calendar (C)java.year (D) java.util (29)What type of value is returned when we use get method of Calendar class with constant DAY_OF_YEAR as an argument? (A)int (B) Char (C) String (D) boolean (30)Which of the following is not a right statement to declare an array named marks in java? (A) int marks[]=new int[3] (B) int[] marks=new int[3] (C) int marks[3]={50,60,70} (D) int marks[]={10,20,30} (31)In java, which of the following is used to represent a collection of homogeneous type of elements? (A)function (B) array (C) procedure (D) switch (32) In java, initial value of array elements are specified into what brackets ? (A) () (B) { } (C) [ ] (D) <> (33)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 (34) In Java,intcompareto(string str) method returns which value if invoking string is equal to str? (A) 0 (B) >0 (C) <0 (D) -1 (35) Which method of java.util.Arrays class is used to fill the whole or partial array with specified value ? (A) sort() (B) put() (C) print() (D) fill() (36) Which method of Date class of java returns a string representing data and time of invoking object? (A) longgetTime() (B) Date(long elapsedTime) (C) void Time(long elapsedTime) (D) String toString() (37) In Java,which of the following methods of string class returns a string after appending str with the invoking string? (A) charindexAt(int index) (B) byte[] getBytes() (C) String concat (String str) (D) String append(String str)
Compiled by Nuzhat Ibrahim Memon 7
Std. 12 (Science) | March – 2019 (38) Which of the following are useful to represent vector, matrix and other multi-dimensional data? (A) Variable (B) Element (C) Array (D) Tag (39) Which of the following refer to the starting index value in arrays? (A) 0 (B) 1 (C) null (D) All of these (40) If ‘intmarks[]={1,2,3,4,5};’ is defined in java what will be the value of marks[3] ? (A) 3 (B) 2 (C) 4 (D) 5 (41) Which of the following constructor is used for without arguments create a string object with no character? (A) String[] (B) String() (C) String{} (D) String(] (42) Which of the following string class method returns true if invoking string is same as str? (A) Boolean equals(string str) (B) Boolean eq(string str) (C)Boolean Equal(string str) (D) boolean Eq(string str) (43) Which of the following string class method returns number of characters in invoking string? (A) int LENGTH() (B) Int Length() (C) int length() (D) Float int length() (44) Which of the following Date class method constructs Date object using current system time? (A) Date(cur()) (B) Date[date()] (C) Date(long()) (D) Date() (45) Date & Calendar class is provided in which of the following package? (A) java.util (B) java.dc (C) java.class (D) java.dateclass (46) Which of the following constant is defined in calendar class for year of calendar? (A) YYYY (B)YRS (C) YY (D) YEAR (47) What is the size of second dimension in an array gseb[5][3]? (A) 3 (B) 5 (C) 15 (D) 18
Std. 12 (General) | March – 2018
(48) Which type of array is used like table of rows and columns? (A) primitive array (B) 1-D array (C) 2-D array (D) minor array (49) int marks[][]=new int[5][3] How many bytes are used in storage space ? (A)15 (B) 5 (C) 3 (D) 60 (50) Which constructor creates a string object which is same as object specified in argument? (A) String(string literal) (B) String (string strobj) (C) String (char ary[]) (D) string() (51) From the following which method of string class return a string with all characters of invoking string converted to upper case? (A) String touppercase() (B) string tolowercase() (C) byte[] getbytes (D) int length() (52) Date class is in which package in Java ? (A) java.io.class (B) java.lang (C) java.util (D) java.io (53)Which 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 (54) If ‘str’ is the object of string class and its content is “I_Like_Computer”, then what is the value of str.length()? (A) 13 (B) 17 (C) 19 (D) 15 (55)What stands for AM & PM in integer constant of calendar class? (A) 0 & 1 (B) 1& 0 (C)1 & 1 (D) 0 & 0 (56)Which braces Is used in 2 D array using comma separated values of data elements? (A) [] (square bracket) (B) {}(curly bracket) (C) () (simple bracket) (D) <> (angled bracket) (57) Which of the following refer to the starting index value in arrays ? (B) 1 (B)0 [zero] (C) null (D) All the given options
Std. 12 (Science) | March – 2018
(58) In Java, array index value starts from which number? (A) 8 (B) 1 (C) -1 (D) 0
Compiled by Nuzhat Ibrahim Memon 8
(59) In Java, initial value for 1-D array are separated using which symbol? (A) –(dash) (B) ,(comma) (C) :(colon) (D) .(full stop) (60)Which of the following is not a correct way to create and initialize an array named marks? (A) int marks[3]={0,10,20}; (B) int[] marks=new int[3]; (C) int marks[]={0,10,20}; (D) int marks[]=new int[3]; (61) sort and fill() are methods of which of the following java calss? (A) java.util.io (B) java.util.Arrays (C) java.io (D) java.string (62) In the following statement for declaring two-dimensional array of Java 5 represent what? Intmarks[][]=new int[5][3]; (A) number of bytes (B) number of columns (C) array size (D) number of rows (63) Which constructor creates a string object which is same as object specified in argument? (A) String (string literal) (B) String (string strobj) (C) String (char ary[]) (D) string() (64) In Java ,intcompareTo(String str) method returns which of the following value if invoking string is greater than str? (A) Logical value (B) >0 (C) <0 (D) 0 (65) Which of the followingmethod of java, returns an array of characters as bytes from invoking string? (A) String to byte() (B) char getByte() (C) byte[] getBytes() (D) String concat() (66)In java, which of the following method of Date class returns a string representing date and time of invoking object? (A) DateText() (B) String toString() (C) Date char() (D) Date() (67) In Java which constant of calendar class returns day number within a week? (A) DATE (B) DAY_OF_MONTH (C) DAY_OF_YEAR (D) DAY_OF_WEEK
Std. 12 (General) | March – 2017
(68)Which of the following constructor is used for without arguments create a string object with no character? (A) String(Charary[]) (B) String() (C) String(String strobj) (D) String(str literal) (69) Which operator can be used to concatenate a string in java? (A) = (B) + (C) & (D) * (70) In java, to search an element in an array, array class provides which type of method? (A) fill() (B) binarySearch() (C)sort() (D) remove() (71) Which type of braces is used to initialize data elements in 1-D aray? (A)<> (B) [] (C) {} (D) () (72) If ‘str’ is the object of string class and its content is “Hello”, then what is the value of str.length()? (A) 8 (B) 7 (C) 6 (D) 5 (73) From the following which method of string class return a string with all characters of invoking string converted to upper case? (A) int length() (B) byte[] getbytes() (C) String toUppercase() (D) String concat(string str) (74) We can use various static methods provided by Java using which array class? (A) java.util.Arrays (B) java.io (C) java.lang (D) All of these (75) which method of date class constructs date object using current system time in Java ? (A) Date &Time() (B) Today’s Date() (C) Date() (D) now() (76) What is the size of second dimension in an array sales[5][12]? (A)5 (B) 12 (C) 60 (D) 11 (77) Arrays are useful to represent which type of data in Java? (A) vector (B) matrix (C) multi-dimensional (D) All of these
Std. 12 (General) | March – 2016
(78) What is a variable representing a collection of homogenous types of elements known in Java? (A) String (B) Array (C) Input (D) Element (79) 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 (80) Date library provides Date class in which package? (A) java.lang (B) java.io (C) java.util (D) java.date
Compiled by Nuzhat Ibrahim Memon 9
(81) Which string method returns number of characters in invoking string in java? (A) intlength() (B) intbyte() (C) intgetByte() (D) intgetlength() (82) Which constant defined for month of calendar of calendar class in Java? (A) month (B) MONTH (C) DATE (D) YEAR (83) Which type of method is used to sort entire or part of array in Java? (A) sort() (B) fill() (C) show() (D) search() (84) In java, string literals, a sequence of characters is enclosed between which sign? (A) ‘ ‘(single quote) (B) “ “(double quotes) (C) <> (D) /*….*/ (85) 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 (86) Which syntax is used to declare 1-dimensional array? (A) <datatype><arrayname>[]; (B) <datatype>[] <arrayname>; (C) Both (A) and (B) (D) <arrayname>[]<datatype>; (87) Which of the following refer to the starting index value in arrays ? (A) 0 (B) 1 (C) null (D) All of these
Std. 12 (General) | March – 2015
(88) 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 (89) In java, how can be array elements accessed using index for each dimension in? (A) [ ] (B) ( ) (C) { } (D) <> (90) In java, which method is used to fill the whole or partial array with specified value ? (A) sort (B) set (C) insert value (D) fill (91) To make a string object which of the following constructors is used to create a string object using 1-D ary argument starting at ary[start] with len number of character? (A) String(char ary[], int start, int len) (B) String(int start, int length) (C) String(int length, int start) (D) String(char ary[], int len) (92) In Java by using which of the following methods of comparing string returns ‘>0’ integer if invoking string is greater than? (A) Boolean equal(String str) (B)Boolean compare to(String str) (C) int compare to(String str) (D) int compare to ignore(String str) (93) Which of the followingmethod of java, returns an array of characters as bytes from invoking string? (A) int length() (B) byte[] getbytes() (C) int bytes() (D) get bytes[] (94) If ‘str’ is the object of String class and its content is “Thank GOD” , then what is the value of str. length? (B) 9 (B) 10 (C) 8 (D) 11 (95) Which 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 (96) 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 (97) 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)