12th Computer CH-9
12th Computer CH-9
2. What do we call the data type that can be used to store a collection of more than
one data values?
a) Scalar b) Composite c) Constructor d) Basic
5. ……………is a 1D data structure that can be used to store list of items in Java.
a) Vector b) Matrix c) Composite d) Static
12. To declare 1–D array we use a pair of …………..brackets after array name or after
data type.
a) [ ] b) { } c) ( ) d) < >
15. How many bytes are used to store the int marks[ ] = new int [5] array?
a) 5 X 4=20 b) 5 X 8=40 c) 5 X 2 =10 d) 5 X 1 =5
17. If we declare “int marks[ ]=new int [5];” array then what is its first and last
element?
a) First is marks[0] & Last is marks[4] b) First is marks[1] & Last is marks[5]
c) First is marks[4] & Last is marks[0] d) First is marks[5] & Last is marks[1]
19. 1-D array is initialized using …………..sign to separate values of data elements in
…….braces.
a) , and { } b) ; and { } c) , and ( ) d) ; and ( )
21. In java, we can not specify both the size of ……….. and ……….values of the array
elements simultaneously while declaring an array.
a) dimensions b) initial c) class d) Both a and b
24. Which method is used to fill the whole or partial array with specified value?
a) fill( ) b) sort( ) c) put( ) d) short( )
25. If you want to assigns value 7 to all elements of list array then which method is
used?
a) fill (list, 7) b) fill (ls,7) c) sort(list,7) d) fill(7)
2
27. To search an element in an array then array class provides which method?
a) Linear search b) binarySearch( ) c) binary d) search()
29. Which of the following arrays are used to store tabular data in the form of rows
and columns?
a) 1D b) 2D c) single d) three dimension
30. If we write “int marks [ ][ ]=new int [5][3]” then which view shows the elements of
array in a table of 5 rows and 3 columns?
a) Logical view b) Physically view c) index view d) Display view
31. In Java, which view of array is stored in memory using contiguous memory?
a) Logical view b) Physically view c) index view d) Display view
32. In statement “int marks [ ][ ]=new int [5][3]” occupy how many memory?
a) 15 (5*3) integers that store 60 (15*4) bytes
b) 15 (5*3) integers that store 15 bytes
c) 15 (5*3) integers that store 30 (15*2) bytes
d) 15 (5*3) integers that store 0 bytes
34. To initialize 2-D array, all these initialized rows are to be enclosed in ………….
braces.
a) Curly { } b) Square [ ] c) circle ( ) d) angular < >
35. In 2-D array all elements in curly braces are separated by …………..sign.
a) comma (,) b) semicolon (;) c) colon( : ) d) dot (.)
36. Size of each row can be known using …………….. property of 1-D array.
a) length b) size c) width d) row
39. Java supports two .types of strings that are handled by which of the following
class?
a) String b) StringBuffer c) character d) Both a and b
3
40. ……………constructor is used without arguments create a string object with no
character.
a) String ( ) b) str( ) c) string( ) d) char()
41. Which type of constructor creates a string object with its initial values using array
argument?
a) String (char ary[ ]) b) String (char ary[ ], int start, int len)
c) String (String strObj) d) String (string literal)
42. Which of the following constructor creates a String object using 1-D array
argument starting at ary [start] with len number of character?
a) String (char ary[ ]) b) String (char ary[ ], int start, int len)
c) String (String strObj) d) String (string literal)
43. Which of the following constructor creates a String object which is same as object
specified in argument?
a) String (char ary[ ]) b) String (char ary[ ], int start, int len)
c) String (String strObj) d) String (string literal)
44. Which of the following constructor creates a String object that refers to the literal
specified in argument?
a) String (char ary[ ]) b) String (char ary[ ], int start, int len)
c) String (String strObj) d) String (string literal)
45. When two String objects are created using same string literals, memory space is
not allocated for …………… object.
a) second b) first c) zero d) null
46. Separate memory is allocated when string objects are created using
………………..operator.
a) new b) obj c) static d) private
47. What happen when we create a String object st1 and st2 without using new
operator?
a) st1 and st2 refer to the same instance as created for st1.
b) Both st1 and st2 refer to different memory location.
c) Only st2 refer to different memory location.
d) Only st1 refer to different memory location.
48. What happen when we create a String object st1 and st2 using new operator?
a) st1 and st2 refer to the same instance as created for st1.
b) Both st1 and st2 refer to different memory location.
c) Only st2 refer to different memory location.
d) Only st1 refer to different memory location.
49. In statement “String st1=new String(“I love India”);” what do we call st1?
a) Reference variable b) String object
c) String class d) character class
4
50. In statement “String st1=new String(“I love India”);” what do we call “I love India”?
a) String Object b) reference variable
c) string class d) character class
51. Which class provides methods to compare strings, find length of string,
combining strings, obtaining sub strings, converting strings, splitting strings,
searching for character or pattern in string etc?
a) String Class b) Character class c) Binary class d) bytecode class
A B
Same as Compare To but case
1 booleanequals(String str) a.
insensitive
booleanequalsIgnoreCase(String
2 b. Return 0, >0, <0 integer.
str)
Return true if invoking string is
3 intcompareTo(String str) c.
same as str.
intcompareToIgnoreCase(String Return true id invoking string is
4 d.
str) same as str after ignoring case.
53. Which method returns an array of characters as byte from invoking string?
a) int length( ) b) byte [ ] getBytes( ) c) String(Bytes) d) getBytes( )
A B
1 int length( ) a. Returns a string with all characters of invoking string
converted to upper.
2 String b. Returns a string with all characters of invoking string
concate(String str) converted to lower.
3 String c. Returns character at index position from the invoking
toLowerCase( ) string, index considered from 0.
4 String d. Returns number of character in invoking string
toUpperCase( )
5 Char indexAt(int e. Returns a string after appending str with the invoking
index) string.
56. Date and Calendar class is provided in which of the following package?
a) java.class b) java.util c) java.dc d) java.dateclass
57. Which class encapsulate both date and time and represents the value using
milliseconds precision?
a) Date b) Calendar c) date d) DATE
58. Which of the following Date method constructs Date object using current system
time?
a) Date (long ()) b) Date( ) c) Date (cur( )) d) Date [date()]
59. Which method returns a string representing date and time of invoking object?
a) long getTime( ) b) String toString( ) c) String( ) d) Date (Long ElapsedTime)
60. Which method sets new date and time of an object using elapsed time?
a) void setTime(long elapsedTime) b) long getTime( )
c) Date( ) d) Date(elapsed time)
61. Which method constructs Date object using specified time in milliseconds elapsed
since January 1, 1970 GMT?
a) Date (long elapsedTime) b) Date ( ) c) Date(time) d) Time(Date)
62. Which method returns nimber of milliseconds since January 1, 1970 GMT?
a) long getTime( ) b) String toString( ) c) Date( ) d) Date(Time)
63. Which class can be used to extract detailed calendar information like year,
month, minute etc.
a) Date class b) Calendar class c) calendar class d) CALENDAR class
6
67. Which constant of Calendar class set minutes?
a) Minute( ) b) MINUTE c) Min( ) d) minute( )
69. Which constant of Calendar class set week number within the month?
a) WEEK_OF_MONTH b) WEEK.OF.MONTH
c) weekof month d) week-of-month
70. Which constant of Calendar class set week number within the year?
a) WEEK_OF_YEAR b) WEEK.OF.YEAR
c) weekofyear d) week-of-year
71. Which constant of Calendar class set day number in the year (1 for the first day)?
a) DAY.OF.YEAR b) DAY_OF_YEAR c) day-of-year d) dayofyear
72. Which constant of Calendar class set Day number within a week (1 for Sunday, 7
for Saturday)?
a) DAY_OF_WEEK b) WEEK_OF_DAY c) week-of-week d) day-of-week
76. Which constant of Calendar class set 0 (Zero) for AM and 1 for PM?
a) AM.PM (b) AM_PM c) am_pm d) am.pm
7
78. In which format GregorianCalendar class constructor takes Date values?
a) MM-DD-YYYY b) YYYY-MM-DD c) YY-MM-DD d) MM-DD-YY
82. What is the size of second dimension in an array gseb [5] [3]?
a) 15 b) 3 c) 5 d) 18
83. Which of the following constructor is used for without argument create a string
object with no character?
a) String[ ] b) String{ } c) String ( ) d) String< >
84. Which of the following string class method returns true if invoking string is same
as str?
a) Boolean Equal (string str) b) Boolean equals ( String str)
c) Boolean eq (string str) d) Boolean Eq (string str)
85. Which of the following is useful to represent vector, matrix and other multi-
dimensional data?
a) Array b) Variable c) Element d) Tag
86. Which of the following refer to the starting index value in arrays?
a) 0 (zero) b) 1 c) null d) All of these
87. If int marks[ ] = {1,2,3,4,5); is defined in Java then what will be the value of
marks[3]?
a) 4 b) 3 c) 2 d) 5
88. 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}
89. In Java, which of the following methods of string class returns a string after
appending str with the invoking string?
a) char indexAt(int index) b) byte[ ] getBytes( )
c) String concat (String str) d) String append(String str)
8
90. 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) 11 d) 8
91. Which method of java.util.Arrays class is used to fill the whole or partial array
with specified value?
a) fill( ) b) sort( ) c) put( ) d) print( )
92. Which of the following symbol signifies the start and end of a JavaScript block?
a) semicolon b) square bracket c) curly bracket d) round bracket
93. In Java, int compareto(String str) method returns which value if invoking string is
equal to str?
a) 0 zero b) > 0 c) <0 d) -1
Textbook Exercise
3.What will expression sales.length return for array sales [5][12]? (Notes: First row)
(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
sales [0][0]?
a) 0 (zero) b) default value c)Compilation Error d) 60
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) 12 d) 8
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