0% found this document useful (0 votes)
178 views22 pages

YPCC ICSE 10th COMP 100 - MCQ File

1. The document contains a 25 question quiz about arrays and strings in Java. 2. The questions cover topics like array declaration and initialization, accessing array elements, array length, string length, string concatenation, and string methods. 3. The quiz is intended to help students practice and learn key concepts about arrays and strings in Java.

Uploaded by

divyansh661799
Copyright
© © All Rights Reserved
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
0% found this document useful (0 votes)
178 views22 pages

YPCC ICSE 10th COMP 100 - MCQ File

1. The document contains a 25 question quiz about arrays and strings in Java. 2. The questions cover topics like array declaration and initialization, accessing array elements, array length, string length, string concatenation, and string methods. 3. The quiz is intended to help students practice and learn key concepts about arrays and strings in Java.

Uploaded by

divyansh661799
Copyright
© © All Rights Reserved
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/ 22

Index Page Sub: Computer Application

JMD HGGM
ICSE Class 10th Semester 2

Section A
1

Array → 25Q

100 MCQs Strings → 25Q

in One Shot Library Classes → 25Q

Encapsulation → 25Q

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→1


1. Arrays in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Q1→ What will this code print ? Rough work Area


int arr[] = new int[5];
System.out.println(arr);
2 a) 0 b) 00000
c) value stored in arr[0] d) Garbage Value

Q2→ Which of the following is advantage of Java array?


a) Code Optimization b) Random access
c) Unlimited size d) Both a) and b)

Q3→ In Java, array elements are stored in ………… memory locations.


a) Random b) Sequential
c) Sequential random d. stacked

Q4→ Which of the following best describes an array ?


a) A data structure that shows a hierarchical behavior
b) Container of objects of similar types
c) Arrays are immutable once initialized
d) Array is not a data structure

Q5→ When does the ArrayIndexOutOfBounds Exception occur ?


a) At compile time
b) At run time
c) It is not an error
d) It is not an exception at all
Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→2
1. Arrays in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area


Q6→ Which of the following is correct usage?
a) int array[-25] b) float arr[25]
3 c) float arr[-25] d) None of these

Q7→ Element arr[10] is which element of the array ?


a) 11 b) 10 c) 9 d) None of these

Q8→ An array element is accessed ………….


a) Using dot operator b) Using an element name
c) Using an index number d) None of these

Q9→ The statement …………………….


Weight[ ] = {26,28,32,31};
a) Assigns 28 to weight[0] b) Assign 28 to weight[1]
c) Assign 32 to weight [3] d) None of these

Q10→ What are the advantages of using arrays?


a. Objects of mixed data types can be stored
b. Elements in an array cannot be sorted
c. Index of first element of an array is 1
d. It is easy to store elements of same data type

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→3


1. Arrays in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area


Q11→ Assuming int takes 4 bytes of memory, what is the size of int arr[15]
a. 15 bytes b. 19 bytes c. 11 bytes d. 60 bytes
4

Q12→ How many of the following are legal declarations?


char [] dog = new char[ ];
char [] tiger = new char[ 1];
char [] horse = new [ ]char;
char [] cat = new [1] char;
a. One b. Two c. Three d. Four

Q13→ In java arrays are ……………………….


a. Objects b. Object references
c. Primitive data type d. None of these

Q14→ We can determine the length of an array using …………….. .


a. Size of (array) b. array.len
c. array.sizeof() d. array.length

Q15→ Write a valid statement to declare a single dimensional array of 5


integers.
a. int arr[] = new int[5];
b. int arr[6] = new int[6];
c. int arr[4] = new int[4];
d. None of these
Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→4
1. Arrays in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2
Q16→ What is printed by the below statements? Rough work Area
int num[] = {3,5,10,12,18};
System.out.println(num[2]+”\t”+num[1]+”\t”+num[3]+”\t”+num[4-2]);
5 a. 3 5 10 12 b. 10 5 12 10
c. 5 10 12 8 d. None of these

Q17→ Write a set of statements that would find and print the size of array.
ar[] = {2,5,6,7,8,9,10};
a. Int len = ar.length;
System.out.println(“The size of array =”+len);
b. int len = ar.length();
System.out.println(“The size of array =”+len );
c. int len = ar.len;
System.out.println(“The size of array =”+len);
d. None of these
Q18→ The first value in the initializer list of an array corresponds to index :
a. 0 b. 1 c. Length -1 d. Length

Q19→ Which of the following cannot have the array type .


a. Integers b. Floats c. Strings d. None of these

Q20→ The size of array is:


a. Fixed b. Can be changed after creation
c. Fixed for integer arrays only d. None of these

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→5


1. Arrays in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2
Q21→ An array index / subscript in java starts from : Rough work Area
a. 1 b. 0 c. -1 d. -99

6 Q22→ If the element 0 an array hold a float, the rest of the pockets will be
of type :
a. int b. float only c. Object d. Any data type

Q23→ Arrays are :


a. Non-mutable
b. Mutable only if they carry strings
c. Mutable at the first and last indexes
d. Mutable at any index

Q24→ The property of an array that gives the number of elements in it is ….


a. Len b. arraysize
c. size d. length

Q25→ Arrays can be called as :


a. Primitive data type
b. Native data types
c. Reference data type
d. All of these

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→6


2. String in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Q26→ The string “Hello boy“ contains …………… characters: Rough work Area
a) 10 b) 9 c) 11 d) None of these

7 Q27→ A string in Java program is written with …………………


a) Single quotes b) < > c) Double quotes d. { }

Q28→ A string
a) begins with a null character b) ends with a null character
c) Both of the above d) None of these
Q29→ Which of these operators can be used to concatenate two or more
String objects?
a) + b) += c) & d) ||

Q30→Which of these method of class String is used to obtain length of String


object?
a) get() b) Sizeof() c) lengthof() d) length()

Q31→ Which of these method of class String is used to extract a single


character from a String object?
a) CHARAT() b) charat() c) charAt() d) ChatAt()

Q32→ Which of these constructors is used to create an empty String object?


a) String() b) String(void)
c) String(0) d) None of the mentioned

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→7


2. String in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Q33→ Which of these method of class String is used to compare two String Rough work Area
objects for their equality?
a) equals() b) Equals() c) isequal() d) Isequal()
8

Q34→ Which of these method of class String is used to check weather a


given object starts with a particular string literal?
a) startsWith() b) endsWith() c) Starts() d) ends()

Q35→ What is the value returned by function compareTo() if the invoking


string is less than the string compared?
a) zero b) value less than zero
c) value greater than zero d) None of the mentioned

Q36→Which of these data type value is returned by equals() method of String


class?
a) char b) int c) Boolean d) All of the mentioned

Q37→ Which of these method of class String is used to extract a substring


from a String object?
a) substring() b) Substring()
c) SubString() d) None of the mentioned

Q38→ A program segment is as follows: int a


a = "tdmalhotra".charAt(4); what will be the result of the segment?
a) a b) 65 c) 4 d) 97
Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→8
2. String in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Q39→ What will s2 contain after following lines of code? Rough work Area
String s1 = "one”;
String s2 = s1.concat("two”)
9 a) one b) two c) onetwo d) twoone

Q40→ What is the value returned by function compareTo() if the invoking


string is more than the string compared?
a) zero b) value less than zero
c) value greater than zero d) None of the mentioned

Q41→ Which of the following statement is correct?


a) replace() method replaces all occurrences of one character in
invoking string with another character.
b) replace() method replaces only first occurrences of a character in
invoking string with another character.
c) replace() method replaces all the characters in invoking string with
another character.
d) replace() replace() method replaces last occurrence of a character
in invoking string with another character.

Q42→ Which of the following method is used to concatenate two strings?


a) add() b) join()
c) concat() d) none of these

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→9


2. String in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area


Q43→ Which of the following can be used to concatenate strings ?
a) +operator b) && operator
10 c) toCharArray d) None of these

Q44→ String declaration is terminated by .....


a) Comma b) Semicolon
c) + d) Quotes

Q45→ String is delimited by ........


a) double Quotes b) Single Quotes.
c) Without Quotes d) none of these.

Q46→ Which of the following methods of String class can be used to test to
strings for equality ?
a) isequal() b) isequals()
c) equal() d) equals()

Q47→ Which of the following methods of class String is used to check


whether a given object starts with a particular string literal ?
a) endswith b) startswith()
c) ends() d) startsWith()

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→10


2. String in Java Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area

11

Q48→ Which of the data type values is returned by equals() method of


String class?
a) String b) boolean
c) char d) void

Q49→ Which of the following methods of String class is used to obtain


character at specified index?
a) char() b) CharAt()
c) int charAt() d) charAt()

Q50→ String in Java is a …………….


a) class b) object.
c) primitive datatype d) character array.

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→11


3. Library Classes Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area


Q51→ A package contains:
a) Tags b) Classes c) Data d) Arrays
12
Q52→ Each primitive data type belongs to a specific:
a) Block b) Object c) Wrapper class d) None of these

Q53→ Automatic conversion of primitive data into an object of wrapper


class is called:
a) Autoboxing b) Shifting c) Explicit conversion d) None

Q54→ The parselnt() function is a member of


a) Integer wrapper class b) Boolean wrapper class
c) Character wrapper class d) None of these

Q55→ The valueOf() function converts:


a) Primitive type to String b) String to primitive type
c) Character to String d) None of these

Q56→ What is the significance of ‘ * ’ while importing a package?


a) It lets you specify that there are 0 or 1 character only
b) It lets you specify that the * may be replaced by any string whatsoever
c) It is the literal ‘ * ’ character itself
d) None of these

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→12


3. Library Classes Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area


Q57→ Differentiate between parselnt() and toString().
a) parselnt separates out the integer based on comma and tostring
13 joins the strings
b) parselnt returns subparts of the integer and toString converts
integers to string.
c) parselnt returns the string converted into an integer and toString
converts any object to string
d) None of these

Q58→ Composite data types are formed by using:


a) Class variables b) Static data types
c) Primitive data type d) Method names

Q59→ Automatic conversion of primitive data into an object of wrapper


class is called:
a) Autoboxing b) Shifting c) Explicit conversion d) None

Q60→ In the given code, what is the value of res? int res = ‘b’;
a) 97 b) 66 c) 65 d) 98

Q61→ Name the package that contains wrapper classes.


a) java.wrap b) java.util
c) java.io d) java.lang

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→13


3. Library Classes Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area


Q62→ Write the purpose of Float.parseFloat().
a) Changes the input string to float
14 b) Changes the float to double
c) Changes the input float to string
d) None of these

Q63→ Write the purpose of Integer.valueOf().


a) Converts String to float
b) Converts int to Integer wrapper object
c) Converts String to Integer wrapper object
d) None of these

Q64→ Write the output of the following program snippet.


char ch = ‘ * ’;
boolean b = Character.isSymbol(ch);
System. out.println (b) ;
a) false b) true c) 1 d) Error

Q65→ Write the output of the following program snippet.


char c = ‘A’;
int n = (int) c+ 32;
System. out.println ( (char) n);
a) ‘B’ b) ‘C’ c) ‘a’ d) None of these

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→14


3. Library Classes Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Q66→ What is the purpose of the below function? Rough work Area
Character. isWhiteSpace ()
a) Checks whether the input is a space
15 b) Checks whether the input is a whitespace
c) Checks whether the input is empty
d) None of these

Q67→ What is the purpose of the below function?


Double.toString ()
a) Converts a String type to a double
b) Converts a String type to Double wrapper object
c) Converts a double data to a String
d) Converts any object to a double

Q68→ What is the output of the following code?


char ch = ‘y’;
char chr = Character.toUpperCase (ch);
int p = (int) chr;
System. out.println (chr+ “\t” +p);
a) Y 89 b) y 121 c) Y 120 d) Y 65

Q69→ In Java, a library of classes is called ___________


a) a folder b) inner class
c) a directory d) an application

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→15


3. Library Classes Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Q70→ What is the output of the following code? Rough work Area
char c = ‘B’;
int i = 4;
16 System.out.println(c+i);
System.out .println( (int) c + i)
a) 70 b) 102 c) f d) F
70 102 102 70

Q71→ Integer is a ________________.


a) Adapter class b) inner class
c) not a class d) Wrapper class

Q72→ Which of these is a wrapper for data type char ?


a) Char b) character c) Character d) char

Q73→ Which of these is a process of converting a simple data type into a


class ?
a) type casting b) Type Conversion
c) type wrapping d) None of these

Q74→ Which of the following classes is not included in java.lang?


a) Class b) Byte c) Array d) Integer

Q75→ Each primitive data type belongs to a specific:


a) Block b) Object c) Wrapper Class d) Sub class
Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→16
4. Encapsulation Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Q76→ Can a private member be accessed by Rough work Area


a) member of the same class?
b) a member of other class?
17 c) a function which id not a member function
d) None of these

Q77→ Distinguishes between instance variables and class variables.


a) local b) public
c) static d) dynamic

Q78→ Read the following class and answer the question that follow:
class Calc {
int rno = 10;
String name=“arti jain”;
void display () {
Calc ob1= new Calc();
System.out.println(ob1.rno);
Calc ob2 = new Calc();
System.out.println(ob2.rno);
}
}
Will the objects ob1 and ob2 store different values for rno & name?

a) No b) yes c) don’t know d) none

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→17


4. Encapsulation Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2
Q79→ Consider the following class : Rough work Area
public class Myclass
{
18
static int a =1 ,b=2;
int m= 12;
public void display()
{
System.out.println(“ a =” + a);
}
}
In the above program code, m is ________ variable.
a) Static variable b)local variable
c) instance variable d)float variable

Q80→ Give the output of the following code:


int a = 10; int b = 20;
String s = Integer.toString(b);
String t = Integer.toString(a);
System.out.println((s+t));
a) 30 b) 20 c) 1020 d) 2010

Q81→ The process of wrapping data and functions together as a unit is


called ________.
a) Abstraction b) Inheritance
c) Polymorphism d) Encapsulation
Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→18
4. Encapsulation Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2
Q82→ Which keyword makes class members accessible outside the class Rough work Area
in which they are declared?
a) Private b) Protected
19
c) Public d) Hidden

Q83→ Give the output of the following code:


int a = 10; int b = 20;
String s = Integer.toString(b);
String t = Integer.toString(a);
System.out.println((s+t));
a) 30 b) 20 c) 1020 d) 2010

Q84→ The process of wrapping data and functions together as a unit is


called ________.
a) Abstraction b) Inheritance
c) Polymorphism d) Encapsulation

Q85→ Which of the following is not wrapper class?


a) Byte b) Int
c) Long d) Float

Q86→ What package is a part of the wrapper class which is imported by


default into all java programs?
a) java.util b) java.lang
c) java.awt d) none of these
Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→19
4. Encapsulation Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area


Q87→ Which access specifier allows accessibility of a member only within
the same class where it is declared ?
20 a) Private b) Protected
c) Public d) default

Q88→ Which keyword allows inheritance?


a) extend b) extends
c) for d) implements

Q89→ The Changes made in a/an ___________variable using one object


will be reflected in other objects.
a) Local Variable b) Static Variable
c) Instance Variable d) Default Variable

Q90→ This type of variable can be used anywhere within a package but
not in the subclasses or outside the package.
a) Local Variable b) Class Variable
c) Default Variable d) Public variable

Q91→ Wrapper class for a ‘char’ data type is :


a) CHAR b) character
c) Character d) char

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→20


4. Encapsulation Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2

Rough work Area


Q92→ The access specifier that provides access to a class and also its
subclasses in a single package :
21 a) public b) private
c) protected d) friendly

Q93→ The package that contains Scanner class and its methods :
a) Java.io b) java.lang
c) java.Math d) java.util

Q94→ The data type int is included in __________wrapper class.


a) Int b) int
c) Integer d) integer

Q95→ A class member declared as _______can be accessed directly by


all the classes within the same package and the subclasses of its class
even if the subclasses are in different packages.
(a) private (b) protected
(c) public (d) final

Q96→ A class object is also known as:


a) Identifier b) Instance variable
c) Modifier d) Specifier

Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→21


4. Encapsulation Sub: Computer Application
JMD HGGM
ICSE Class 10th Semester 2
Q97→ A class contains: Rough work Area
a) Attributes and methods
b) A number of object of same type
22
c) data and member function
d) All of the above

Q98→ The function that changes the state of an object is known as:
a) Pure function b) impure function
c) mix function d) Replace function

Q99→ A function with many definitions is called:


a) Multiple function b) Function overloading
c) Floating function d) None

Q100→ Which of the following type can be used for a not returnable
functions.
a) int b) float c) double d) void

Q101→ A function is invoked through an:


a) Object b) System c) Parameter d) None

Q102→ A member variable declared with a private access specifier has


visibility in _____________.
a) class b) subclass
c) package d) All of these
Practice Makes Perfect WWW.YPComputerClasses.in 7798161873 p→22

You might also like