Well-structured Std 12 Computer Textbook MCQ Answers and Std 12 Computer MCQ Answers Ch 9 Working with Array and String can serve as a valuable review tool before computer exams.
GSEB Std 12 Computer Chapter 9 MCQ Working with Array and String
Question 1.
Basic variable can store only one value. Such variable is known as …………….. .
(A) constant variable
(B) scalar variable
(C) modular variable
(D) (A) or (B)
Answer:
(D) (A) or (B)
Question 2.
What is an array ?
(A) A collection of homogeneous type of elements
(B) A collection of different type of elements
(C) A collection representing different variable
(D) (A) or (C)
Answer:
(A) A collection of homogeneous type of elements
Question 3.
Array can represent ………………. data.
(A) vector
(B) matrix
(C) multi-dimensional
(D) all of these
Answer:
(D) all of these
Question 4.
………….. type of list can be stored in 1-D array.
(A) Characters
(B) Numbers
(C) (A) and (B) both
(D) (A) or (B)
Answer:
(C) (A) and (B) both
Question 5.
………………… type of data can be stored in 2-D array.
(A) Tabular
(B) Matrix
(C) (A) and (B) both
(D) (A) or (B)
Answer:
(D) (A) or (B)
Question 6.
What is Index position in array ?
(A) Each element of an array
(B) Sequence of an array
(C) Value of each array element
(D) None of these
Answer:
(A) Each element of an array
Question 7.
………………. is false about an array.
(A) Array is the word used to manage the list of things in java.
(B) Array creation is the process of three steps
(C) Array object can be created using two ways.
(D) When same task to be done different elements then array is used.
Answer:
(B) Array creation is the process of three steps
Question 8.
How many steps are there to create an array ?
(A) 2
(B) 3
(C) 4
(D) 5
Answer:
(A) 2
Question 9.
How many ways array object can be created ?
(A) 3
(B) 4
(C) 2
(D) Only one
Answer:
(C) 2
Question 10.
……………. method is used to create an array.
(A) Using new operator and defining its size
(B) To directly initialize the value to array elements.
(C) (A) or (B)
(D) (A) and (B) both
Answer:
(C) (A) or (B)
Question 11.
…………….. bracket is used to declare 1-D array.
(A) ( )
(B) { }
(C) [ ]
(D) < >
Answer:
(C) [ ]
Question 12.
……………. syntax is true to declare 1-D array.
(A) <data type> <array name> [ ];
(B) <data type> [ ] <array name>;
(C) (A) and (B) both
(D) <data typo [ ] {array name};
Answer:
(C) (A) and (B) both
Question 13.
……………. is the wrong way to declare to marks array.
(A) int marks [ ] = int[5];
(B) int marks [ ] = new int [5];
(C) int [ ] marks = new int [5];
(D) All of these
Answer:
(A) int marks [ ] = int[5];
Question 14.
int marks[ ] = new int [5] , then which is true about this array ?
(A) Marks is the name of an array.
(B) Stores the five integer values.
(C) Indicates the indexes also.
(D) All of these
Answer:
(D) All of these
Question 15)
How many bytes are used to store integer value using int data type ?
(A) 2
(B) 4
(C) 8
(D) Only one
Answer:
(B) 4
Question 16.
int marks [ ] = new int [5] , how many bytes will be required by marks array ?
(A) 15
(B) 20
(C) 18
(D) 5
Answer:
(B) 20
Question 17.
What do we give in the [] after the array name ?
(A) Index
(B) Subscript
(C) (A) or (B)
(D) None of these
Answer:
(C) (A) or (B)
Question 18.
What is index or subscript ?
(A) Location of element in array
(B) Numerical content
(C) Textual content
(D) All of these
Answer:
(A) Location of element in array
Question 19.
Index value starts with …………….. .
(A) 0
(B) 1
(C) -1
(D) 5
Answer:
(A) 0
Question 20.
What does 2 suggest in marks [2] ?
(A) Index of element
(B) Value of element
(C) Total elements
(D) All of these
Answer:
(A) Index of element
Question 21.
What will be the value of marks [3] in int marks [ ] = {90, 60, 70, 65, 80} ?
(A) 70
(B) 65
(C) 3
(D) 80
Answer:
(B) 65
Question 22.
What does mark[0] indicate ?
(A) Value of marks variable is zero.
(B) Last element of array
(C) First element of array
(D) Such array variable is not possible
Answer:
(C) First element of array
Question 23.
Elements in 1-D array are separated using ………………. .
(A) [ ]
(B) { }
(C) ( )
(D) < >
Answer:
(B) { }
Question 24.
………….. syntax is not true for declaring marks array.
(A) int marks [ ] = {90, 70, 77};
(B) int [ ] marks = {90, 70, 77};
(C) int [3] marks = {90, 70, 77};
(D) All of these
Answer:
(C) int [3] marks = {90, 70, 77};
Question 25.
If we initialize the values of variables directly then …………….. operator is not needed.
(A) new
(B) create
(C) array name
(D) all of these
Answer:
(A) new
Question 26.
……………… class method is used to display the value of array elements.
(A) println()
(B) printf()
(C) display()
(D) displayed()
Answer:
(C) display()
Question 27.
…………….. class method is given when array is used in java.
(A) Using private static
(B) Using public static
(C) Using protect static
(D) This is not possible
Answer:
(B) Using public static
Question 28.
What can not be given simultaneously while declaring the array in java ?
(A) Array name and size of dimension
(B) Size of dimension and initial values of elements
(C) Array name and number of elements
(D) Any of above
Answer:
(B) Size of dimension and initial values of elements
Question 29.
What is the use of static method provided by , java.util.Arrays class ?
(A) Compare two arrays
(B) Find the particular element in array
(C) Sort the array
(D) All of these
Answer:
(D) All of these
Question 30.
Which elements are sorted by giving java.util.Arrays.sort (list 1, 5) ?
(A) list [1] to list [5]
(B) list [1] to list [5 – 1]
(C) list [0] to list [5 – 1]
(D) None of these
Answer:
(B) list [1] to list [5 – 1]
Question 31.
To change the elements with some other values, ……………. method can be used.
(A) fill
(B) list
(C) sort
(D) full
Answer:
(A) fill
Question 32.
Which arrays elements are changed by giving java.util.Arrays.fill(list 7) ?
(A) All elements of array are filled with 7.
(B) 7th element of array is filled with 7.
(C) All elements after 7th are filled with 7
(D) Error message occurs.
Answer:
(A) All elements of array are filled with 7.
Question 33.
java.util.Arrays.fill(list 2, 6, 5) , Which elements will be filled with 5 ?
(A) list [2] to list [5]
(B) list[2] to list[6 – 1]
(C) list[2] to list[6]
(D) Error message occurs
Answer:
(B) list[2] to list[6 – 1]
Question 34.
………….. method is used to find the particular element in an array.
(A) binaryFind() method
(B) binarySearch() method
(C) display() method
(D) Search() method
Answer:
(B) binarySearch() method
Question 35.
…………….. method can be used to compare the given value with each element of an array.
(A) Linear search
(B) Random search
(C) Only search
(D) Non-linear method
Answer:
(A) Linear search
Question 36.
When a particular element is searched using binarySearchO and if the element is not found then ……………… value is returned.
(A) 0
(B) 1
(C) – 1
(D) error occurs
Answer:
(C) – 1
Question 37.
When a particular element is searched using binarySearch() and if the element is found then …………….. value is returned.
(A) index position of an element
(B) value of an element
(C) error message occurs
(D) 1
Answer:
(A) index position of an element
Question 38.
How is the data stored in 2-D array ?
(A) In the form of row and column
(B) In a tabular form
(C) (A) and (B) both
(D) (A) or (B)
Answer:
(D) (A) or (B)
Question 39.
Pair of ……………… brackets are used to declare 2-D array in java.
(A) ( ) ( )
(B) [ ] [ ]
(C) { } { }
(D) < > < >
Answer:
(B) [ ] [ ]
Question 40.
How many values can be stored using int marks [ ] [ ] = new int[5] [3] ?
(A) 5
(B) 3
(C) 15
(D) 20
Answer:
(C) 15
Question 41.
Size of ………………. is indicated by first bracket in int marks [ ] [ ] = new int [5] [3] .
(A) rows
(B) column
(C) cell
(D) none of these
Answer:
(A) rows
Question 42.
Size of …………… is indicated by second bracket in int marks [ ] [ ] = new int[5] [3] .
(A) rows
(B) column
(C) cell
(D) none of these
Answer:
(B) column
Question 43.
How much size is occupied by marks variable by int marks [ ] [ ] = new int [5] [3] ?
(A) 15
(B) 60
(C) 5
(D) 3
Answer:
(B) 60
Question 44.
Maximum …………. dimension can be given to make 2-D array.
(A) [8] [8]
(B) [255] [255]
(C) [16] [16]
(D) There is no limit
Answer:
(D) There is no limit
Question 45.
In 2-D array, row is taken as …………….. array element.
(A) 1-D
(B) infinite
(C) 2-D
(D) multi
Answer:
(A) 1-D
Question 46.
To give the initial values to each element in 2-D array, the values separated by comma are given in ……………. brackets.
(A) [ ]
(B) ( )
(C) { }
(D) < >
Answer:
(C) { }
Question 47.
To give the initial values to each element in 2-D array, the values separated by ……………. are given in curly brackets.
(A) (,)
(B) (;)
(C) (:)
(D) (#)
Answer:
(A) (,)
Question 48.
What is the meaning of ‘array within array’ in Java ?
(A) 1-D array
(B) Multi array
(C) 2-D array
(D) None of these
Answer:
(C) 2-D array
Question 49.
Which property is used to count the number of elements in 1-D array ?
(A) total
(B) length
(C) totaldig
(D) number
Answer:
(B) length
Question 50.
What is the use of length property in 2- array ? 59)
(A) Returns the number of rows.
(B) Returns the number of columns.
(C) counts the length of a string
(D) None of these
Answer:
(A) Returns the number of rows.
Question 51.
If length property is used with the array name then ……………. is displayed in the output.
(A) size of second dimension
(B) number of dimensions
(C) size of first dimension
(D) number of elements
Answer:
(C) size of first dimension
Question 52.
Array size can be mentioned in ……………. brackets.
(A) { }
(B) < >
(C) []
(D) ( )
Answer:
(C) []
Question 53.
Position of index start with …………….. .
(A) 0
(B) – 1
(C) 1
(D) 2
Answer:
(A) 0
Question 54.
What is a string ?
(A) One type of a character
(B) Series of characters
(C) Special type of character
(D) None of these
Answer:
(B) Series of characters
Question 55.
Strings are enclosed in ………….. brackets.
(A) double quotes
(B) sings quotes
(C) curly
(D) square
Answer:
(A) double quotes
Question 56.
Which statement is false related to strings in Java ?
(A) Group of characters means a string
(B) There are three types of strings in Java.
(C) Strings are controlled using the classes like ‘String’ and ‘StringBuffer’
(D) Strings are enclosed in double quotes
Answer:
(B) There are three types of strings in Java.
Question 57.
…………….. constructor will create a string object without any character.
(A) String (char ary [ ])
(B) String( )
(C) String (String strobj)
(D) String (String literal)
Answer:
(B) String( )
Question 58.
Which constructor will create a string object using variable’s initial value ?
(A) String (char ary[ ])
(B) String()
(C) String (String String)
(D) String (String literal)
Answer:
(A) String (char ary[ ])
Question 59.
char name [] = {‘S’, ‘A’, ‘N’, ‘J’, ‘Y’{;
String str = new String (name, 1, 3);
System.out.println(str3);
What will be the output ?
(A) SAN
(B) ANJ
(C) NIY
(D) SJY
Answer:
(B) ANJ
Question 60.
If String str=”Divyakant Sir” then which of the following constructor can create same string object as str ?
(A) String()
(B) String(String strObj)
(C) String(String literal)
(D) String(char ary [ ])
Answer:
(B) String(String strObj)
Question 61.
Each character occupies ……………. bytes in Java.
(A) 2
(B) 4
(C) 6
(D) 1
Answer:
(A) 2
Question 62.
…………. data type should be used instead of char to include a character using less space.
(A) String
(B) Character
(C) bytes
(D) number
Answer:
(C) bytes
Question 63.
If two strings are same the using …………… operator different locations are assigned in the memory.
(A) create
(B) new
(C) CREATE
(D) Set
Answer:
(B) new
Question 64.
If two string objects are created using same string literal then what is done for the second object by the memory ?
(A) Does not allocate the space
(B) Allocates double space
(C) Allocates space
(D) Nothing is done
Answer:
(C) Allocates space
Question 65.
…………… is the facility of string class method.
(A) To compare two strings
(B) To get the length of strings
(C) To concatenate two strings
(D) All of these
Answer:
(D) All of these
Question 66.
If the string and parameter str(object) are same then ……………….. value is returned.
(A) True
(B) False
(C) Wrong
(D) Error
Answer:
(A) True
Question 67.
If the method calling string object is same as parameter str then …………….. value is returned.
(A) – 1
(B) 0
(C) 1
(D) < 0
Answer:
(B) 0
Question 68.
………….. method is not provided by the string class.
(A) To get number of words
(B) To divide the string into substrings
(C) To separate some part of a string
(D) To append the string at the end of another string
Answer:
(A) To get number of words
Question 69.
………….. method is provided by string class.
(A) To convert the characters of a string to uppercase or lowercase.
(B) String or its part to be copied
(C) To convert the string to bytes array.
(D) All of these
Answer:
(D) All of these
Question 70.
……………… method returns the number of characters lying in the string object.
(A) int len()
(B) int length()
(C) int count()
(D) int encount())
Answer:
(B) int length()
Question 71.
…………….. method converts the characters of an array to the byte array.
(A) byte [ ]
(B) getBytes [ ]
(C) byte [ ] getBytes [ ]
(D) getBytes()
Answer:
(C) byte [ ] getBytes [ ]
Question 72)
………….. method converts all the characters of a string to the small letter characters.
(A) LowerCase( )
(B) String toLowerCase()
(C) String toLowercase [ ]
(D) lowercase()
Answer:
(B) String toLowerCase()
Question 73.
String str = “Saraswati Vidhyalaya”;
System. out.println(str.length ());
What will be the output of this program ?
(A) 18
(B) 19
(C) 20
(D) 21
Answer:
(B) 19
Question 74.
What is the meaning of length for array variable ?
(A) Method
(B) Attribute
(C) Properties
(D) (B) or (C)
Answer:
(D) (B) or (C)
Question 75.
What is the meaning of length for string object ?
(A) Method
(B) Attribute
(C) Function
(D) Properties
Answer:
(A) Method
Question 76.
Which method is not available for string class in Java ?
(A) To cut some part of the string
(B) To get the particular character for the given index position
(C) To reverse the string
(D) To divide the string to the substrings
Answer:
(C) To reverse the string
Question 77.
Date class facility is available in …………… package of Java.
(A) java.utilities
(B) java.char
(C) java.util
(D) java.prop
Answer:
(C) java.util
Question 78.
……………. method can create Date object using current time of system.
(A) Date[ ]
(B) Date( )
(C) Time( )
(E) Time[ ]
Answer:
(B) Date( )
Question 79.
…………. package has the feature of using Calendar class.
(A) java.lib.util
(B) java.util
(C) java.utilities
(D) jav.libprop
Answer:
(B) java.util
Question 80.
…………….. subclass of Calendar class is used in our syllabus.
(A) GeoCalendar
(B) GregorianCalendar
(C) StandardCalendar
(D) MainCalendar
Answer:
(B) GregorianCalendar
Question 81.
Since ………………. total milliseconds are returned by the method longger Time().
(A) January 1, 1990 GMT
(B) January 1, 1980 GMT
(C) January 1, 1970 GMT
(D) January 26, 1947 GMT
Answer:
(C) January 1, 1970 GMT
Question 82.
Using …………….. method of Calendar class we can set the field constants.
(A) Set
(B) get
(C) set
(D) Get
Answer:
(C) set
Question 83.
If the calendar is the object of Calendar class then ……………….. date is set by giving calendar.set(Calendar.DATE, 20).
(A) 10
(B) 20
(C) 30
(D) 1
Answer:
(B) 20
Question 84.
…………….. is a variable representing a collection of homogeneous type of elements.
(A) Arrangement
(B) Array
(C) Assortment
(D) Group
Answer:
(B) Array
Question 85.
…………….. is used to represent two dimensional (2-D) data structures like table or rows and columns.
(A) Vector
(B) Path
(C) Matrix
(D) Route
Answer:
(C) Matrix
Question 86.
Array with …………… dimension is known as 1-D array.
(A) double
(B) triple
(C) (A) and (B) both
(D) single
Answer:
(D) single
Question 87.
Instead of declaring individual variables like marks 1, marks2, marks3, marks4, marks5; one can declare array ………………. .
(A) marks[5]
(B) mark[5]
(C) marksf 1-5]
(D) All of these
Answer:
(A) marks[5]
Question 88.
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[l], marks[2], marks[3], marks [4],
(D) marks[-1], marks[0], marks[1], marks[2], marks [3].
Answer:
(C) marks[0], marks[l], marks[2], marks[3], marks [4],
Question 89.
For example, to store the marks obtained by a , student in five tests in Mathematics subject, an
array of …………….. integer elements can be used.
(A) five
(B) six
(C) four
(D) seven
Answer:
(A) five
Question 90.
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
Answer:
(B) 0 to 4
Question 91.
In array variable marks [5] , marks [0] refers to the …………….. element.
(A) last
(B) second
(C) first
(D) none of these
Answer:
(C) first
Question 92.
The array size is same as the number of values specified in …………… .
(A) braces
(B) index
(C) default value
(D) initialization
Answer:
(A) braces
Question 93.
Methods sort() and fill() are part of ……………. class.
(A) Java.Arrays
(B) java.util
(C) java.util.Arrays
(D) All of these
Answer:
(C) java.util.Arrays
Question 94.
int marks [ ] [ ] = new int [5] [3], the logical view of array elements is a table of ……………
(A) 3 rows and 5 columns
(B) 15 columns
(C) 5 rows and 3 columns
(D) 15 rows
Answer:
(C) 5 rows and 3 columns
Question 95.
1-D array of ……………. can be considered as a string.
(A) spaces
(B) groups
(C) characters
(D) columns
Answer:
(A) spaces
Question 96.
String ( ) without arguments create a …………… object with no character.
(A) string
(B) character
(C) buffer
(D) code
Answer:
(A) string
Question 97.
To save space, if the characters are ……………, an array of bytes should be used instead of array of characters.
(A) ASCII
(B) coded
(C) ACSII
(D) ACIIS
Answer:
(A) ASCII
Question 98.
String strl=”Divyakant Sir”;
String str2=”Sanjay Sir”;
System. out.prin tin (str 1 .compareTo (str2));
What will be the output of this program ?
(A) 0
(B) >0
(C) < 0
(D) None of these
Answer:
(C) < 0
Question 99.
Method void ……………. copies characters of invoking string fromlndx to tolndx-l to target array from targetlndx onwards.
(A) toUpperCase()
(B) toLowerCase()
(C) concat(String str)
(D) getChars (intfromlndx, inttolndx, char target[], inttargetlndx)
Answer:
(D) getChars (intfromlndx, inttolndx, char target[], inttargetlndx)
Question 100.
With array variable, length is an ……………… or property of array.
(A) attribute
(B) method
(C) string
(D) none of these
Answer:
(C) string
Question 101.
Java library also provides ………………… class in java.util package.
(A) data
(B) string
(C) time
(D) date
Answer:
(D) date
Question 102.
Method long …………….. returns number of milliseconds since January 1, 1970 GMT.
(A) Date (long elapsed Time)
(B) Date()
(C) toString()
(D) getTime()
Answer:
(D) getTime()
Question 103.
Array are passed to a function argument by ……………..
(A) value
(B) reference
(C) both value and reference
(D) none of these
Answer:
(B) reference
Question 104.
If an array is declared as a[10], then its elements will be stored as ……………….. .
(A) a[l] to a[10]
(B) a[l] to a[9]
(C) a[0] to a[9]
(D) a[0] to a[10]
Answer:
(C) a[0] to a[9]
Question 105.
If ‘str’ 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
Answer:
(B) 15
Question 106.
Method getTime() returns ……………. data type.
(A) long
(B) String
(C) void
(D) Date
Answer:
(A) long
Question 107.
What is the full form of GMT ?
(A) Greenwich Median Time
(B) Greenwich Mode Time
(C) Greenwich Modern Time
(D) Greenwich Mean Time
Answer:
(D) Greenwich Mean Time
Question 108.
Match the following.
Constant | Description |
(a) YEAR | (1) 0 for AM, 1 for PM |
(b) MONTH | (2) Week number within the month |
(c) DATE | (3) Day number within a week (1 for Sunday, 7 for Saturday) |
(d) DAY_OF_MONTH | (4) Week number within the year |
(e) HOUR | (5) Hour in 24-hour notation |
(f) IIOUR_OF_DAY | (6) Second |
(g) MINUTE | (7) Day number in the year (1 for the first day) |
(h) SECOND | (8) Hour in 12-hour notation |
(i) AM_PM | (9) Year of calendar |
(j) DAY_OF_WEEK | (10) Day of Calendar month |
(k) WEEK_OF_MONTH | (11) Month of Calendar (0 for January1, 11 for December) |
(l) WEEK_OF_YEAR | (12) Same as DATE |
(m) DAY_OF_YEAR | (13) Minute |
Answer:
(a – 9) (b – 11) (c – 10) (d – 12) (e – 8) (f – 5) (g – 13) (h – 6) (i – 1), (j – 3) (k – 2) (l – 4) (m – 7)
Constant | Description |
(a) YEAR | (9) Year of calendar |
(b) MONTH | (11) Month of Calendar (0 for January1, 11 for December) |
(c) DATE | (10) Day of Calendar month |
(d) DAY_OF_MONTH | (12) Same as DATE |
(e) HOUR | (8) Hour in 12-hour notation |
(f) IIOUR_OF_DAY | (5) Hour in 24-hour notation |
(g) MINUTE | (13) Minute |
(h) SECOND | (6) Second |
(i) AM_PM | (1) 0 for AM, 1 for PM |
(j) DAY_OF_WEEK | (3) Day number within a week (1 for Sunday, 7 for Saturday) |
(k) WEEK_OF_MONTH | (2) Week number within the month |
(l) WEEK_OF_YEAR | (4) Week number within the year |
(m) DAY_OF_YEAR | (7) Day number in the year (1 for the first day) |