STUDY MATERIAL LOGIN JOIN NOW
Home / Class 10 - APC Understanding Computer Applications with BlueJ / Library Classes
CONTENTS
Search by lesson title Chapter 2
Library Classes
Multiple Choice Questions
Chapter 1 - Unit 1 Fill in the blanks
Introduction to Object Oriented
Programming Concepts Class 10 - APC Understanding Computer Applications with State True or False
Find the output of the
Chapter 1 - Unit 2 BlueJ following program snippets
Elementary Concept of Objects and Case-Study based question
Classes
Write the purpose of the
following functions
Chapter 1 - Unit 3
Values and Data Types Answer the following
questions
Chapter 1 - Unit 4 Solutions to Unsolved Java
Operators in Java Programs on Character
Manipulations
Chapter 1 - Unit 5a
Introduction to Java
Chapter 1 - Unit 5b
Input in Java
Chapter 1 - Unit 6
Mathematical Library Methods
Chapter 1 - Unit 7
Conditional Statements in Java
Chapter 1 - Unit 8
Iterative Constructs in Java
Chapter 1 - Unit 9
Nested Loop
Chapter 1 - Case Study
Case Study based questions from
revision of Class IX Syllabus
Chapter 2 Multiple Choice Questions
Library Classes
Chapter 3
Arrays
Question 1
Chapter 4
String Handling
Chapter 5
A package contains:
User Defined Methods
Chapter 6
Class as the Basis of All Computation
1. tags
Chapter 7
Constructors
2. classes
3. data
Chapter 8
Encapsulation and Inheritance
4. arrays
Answer
classes
Reason — A package is a collection of Java
classes.
Question 2
Each primitive data type belongs to a
specific
1. block
2. object
3. wrapper class
4. none
Answer
wrapper class
Reason — A wrapper class is a class that
contains a primitive data type.
Question 3
Automatic conversion of primitive data into
an object of wrapper class is called
1. autoboxing
2. explicit conversion
3. shifting
4. none
Answer
autoboxing
Reason — Automatic conversion of primitive
data into an object of its equivalent wrapper
class is called autoboxing.
Question 4
The parseInt() function is a member of
1. integer wrapper class
2. character wrapper class
3. boolean wrapper class
4. none
Answer
integer wrapper class
Reason — The parseInt() function is a
member of integer wrapper class.
Question 5
valueOf() function converts
1. Primitive type to String
2. String to primitive type
3. character to String
4. None
Answer
String to primitive type
Reason — valueOf() function converts String
to primitive type.
Question 6
Which of the following functions checks
whether a character is a blank or not?
1. [Link]( )
2. [Link]( )
3. [Link]( )
4. [Link]( )
Answer
[Link]( )
Reason — [Link]( )
returns a boolean type value true if the
given argument is a white space and
otherwise, it returns false.
Question 7
Which of the following statements is true?
1. [Link]( ) and
[Link]( ) are same.
2. [Link]( ) and
[Link]( ) are same.
3. parse and valueOf functions are same.
4. [Link]( ) and
[Link]( ) are same.
Answer
parse and valueOf functions are same.
Reason — parse and valueOf functions are
used to convert a string to a primitive data
type.
Question 8
The variable must be declared ........ type, if
a character is to be assigned to it.
1. char
2. ch
3. character
4. alphanumeric
Answer
char
Reason — The variable must be declared
'char' type, if a character is to be assigned
to it.
Fill in the blanks
Question 1
Package is a collection of classes.
Question 2
By default, [Link] package is imported in
a Java program.
Question 3
The user can create a data type by using a
class.
Question 4
The data type int is included in Integer
wrapper class.
Question 5
Wrapper class uses first letter in upper
case.
Question 6
String data is converted to float type by
using [Link](String) function.
Question 7
Conversion from primitive type to wrapper
object is called as autoboxing.
Question 8
Each character oriented function uses a
wrapper tag Character.
State True or False
Question 1
Java class library includes all the packages.
True
Question 2
Wrapper classes belong to [Link]
package.
False
Question 3
Array is a non-primitive data type.
True
Question 4
Class is a composite data type.
True
Question 5
[Link]() converts integer data to
String.
True
Find the output of the following
program snippets
Question 1
char ch = '*';
boolean b = [Link](ch);
[Link](b);
Answer
Output
false
Explanation
As Asterisk (*) is not a letter so
[Link]() method returns
false.
Question 2
char c = 'A';
int n = (int) c + 32;
[Link]((char)n);
Answer
Output
Explanation
int n = (int) c + 32 ⇒ 65 + 32 ⇒ 97
So, variable n get the value of 97. 97 is the
ASCII code of small 'a' so casting n to
char, prints 'a' to the console.
Question 3
String s= "7";
int t =[Link](s);
t = t + 1000;
[Link](t);
Answer
Output
1007
Explanation
[Link]() converts "7" into an
int value i.e. the decimal number 7. t +
1000 adds the number 7 to 1000 giving
1007 as the output.
Question 4
char c = 'B';
int i = 4;
[Link](c + i);
[Link]((int)c + i);
Answer
Output
70
70
Explanation
In the expression c + i , c is of type
char and i is of type int . As int is the
higher type so char gets promoted to
int . Thus, ASCII code of 'B' which is 66 is
added to 4 giving the output as 70. This is
an example of implicit type conversion.
In the next expression (int)c + i , c
which is of char type is explicitly casted to
int . Again, ASCII code of 'B' which is 66 is
added to 4 giving the output as 70. This is
an example of explicit type conversion.
Question 5
char ch = 'y';
char chr = [Link](ch);
int p = (int) chr;
[Link](chr + "\t" + p);
Answer
Output
Y 89
Explanation
[Link]() method converts
small y to capital Y so chr gets the value of
'Y'. Casting chr to int gives the ASCII
code of 'Y' which is 89.
Question 6
int n = 97;
char ch = [Link]((char)n
[Link](ch + " Great Victory
Answer
Output
A Great Victory
Explanation
97 is the ASCII code of small a so
[Link]((char)n) returns
capital A which is stored in ch .
Question 7
char ch = 'x'; int n = 5;
n = n + (int)ch;
char c = (char)n;
[Link]((char)((int)c-26));
Answer
Output
Explanation
As ASCII code of 'x' is 120, so the expession
n + (int)ch ⇒ 5 + 120 ⇒ 125. After that,
the expression (char)((int)c-26) ⇒
(char)(125 - 26) ⇒ (char)99 ⇒ 'c' as ASCII
code of 'c' is 99. So, c is the final output.
Question 8
char ch = 'A';
char chr = [Link](ch);
int n = (int)chr-32;
[Link]((char)n + "\t" + chr
Answer
Output
A a
Explanation
[Link]() converts 'A' to
'a'. ASCII code of 'a' is 97. n becomes 65
— (int)chr-32 ⇒ 97 - 32 ⇒ 65. 65 is the
ASCII code of 'A'.
Case-Study based question
Question 1
Java language uses each primitive data
type under a specific packet. Other than a
data type, the packet also contains the
functions to convert the primitive type into
string and vice versa. The computer uses
128 ASCII characters. Each character is
assigned a specific numeric code called
ASCII code. Java language also has the
facility to convert the characters into the
ASCII code and vice versa.
Based on the above discussion, answer the
following questions:
(a) What is the name given to the packet
containing a primitive data type?
(b) What is the function used to convert a
string data into integer type?
(c) Name the term used to convert a
primitive data into the object of its wrapper
class.
(d) What is the syntax to convert a string
"24" into integer data type?
Answer
(a) Wrapper class
(b) parseInt() or valueOf()
(c) Autoboxing
(d) int num = [Link]("24");
Write the purpose of the following
functions
Question 1
[Link]()
Answer
It is used to convert string data into float
data.
Question 2
[Link]()
Answer
It is used to convert double data to a string.
Question 3
[Link]()
Answer
It is used to convert string data into the
Integer wrapper object.
Question 4
[Link]()
Answer
It is used to check if the character given as
its argument is a digit.
Question 5
[Link]()
Answer
It is used to check if the character given as
its argument is a whitespace.
Answer the following questions
Question 1
What is a package?
Answer
In Java, a package is used to group related
classes. Packages are of 2 types:
1. Built-In packages — These are provided
by Java API
2. User-Defined packages — These are
created by the programmers to
efficiently structure their code.
[Link], [Link] are examples of
built-in packages.
Question 2
What is the significance of '*' while
importing a package?
Answer
The asterisk(*) sign indicates that all the
classes of the imported package can be
used in the program.
Question 3
Define a wrapper class.
Answer
The wrapper class is a class that contains a
primitive data type. Whenever an object to a
wrapper class is created, a field in memory
is allocated to contain a primitive data.
Wrapper classes are present in [Link]
package. The different wrapper classes
provided by Java are Boolean, Byte, Integer,
Float, Character, Short, Long and Double.
Question 4(a)
Differentiate between isUpperCase() and
toUpperCase()
Answer
isUpperCase() toUpperCase()
It is used to check It is used to
if the character convert the
given as its character given as
isUpperCase() toUpperCase()
argument is in its argument to
upper case or not. upper case.
Its return type is Its return type is
boolean. char.
Question 4(b)
Differentiate between parseInt() and
toString() functions
Answer
parseInt() toString()
It converts a string It converts an
to an integer. integer to a string.
Its return type is Its return type is
int. String.
Question 4(c)
Differentiate between primitive type and
composite type data
Answer
Primitive Data Composite Data
Types Types
Primitive data types Composite data
are fundamental types are created
data types of Java.
Primitive Data Composite Data
Types Types
by using primitive
data types.
Primitive data types
Composite data
are built-in data
types are defined
types defined by
by the
Java language
programmer.
specification.
Examples of
Examples of
primitive data types
composite data
are byte, short, int,
types are Class
long, float, double,
and Array.
char, boolean.
Question 5(a)
int res = 'A';
What is the value of res?
Answer
Value of res is 65.
Question 5(b)
Name the package that contains wrapper
classes.
Answer
[Link] package contains wrapper
classes.
Question 5(c)
Write the prototype of a function check
which takes an integer as an argument and
returns a character.
Answer
char check(int n) takes an integer as an
argument and returns a character.
Solutions to Unsolved Java Programs
on Character Manipulations
Question 1
Write a program in Java to input a
character. Find and display the next 10th
character in the ASCII table.
import [Link];
public class KboatTenthChar
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter a chara
char ch = [Link]().charAt(0);
char nextCh = (char)(ch + 10);
[Link]("Tenth chara
+ ch + " is " + nextCh);
}
}
Output
Question 2
Write a program in Java to input a
character. Display next 5 characters.
import [Link];
public class KboatFiveChars
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter a chara
char ch = [Link]().charAt(0);
[Link]("Next 5 char
+ ch + " are:");
for (int i = 1; i <= 5; i++) {
[Link](++ch);
}
}
}
Output
Question 3
Write a program in Java to generate all the
alternate letters in the range of letters from
A to Z.
public class KboatAlternateLetters
{
public static void main(String arg
for (char ch = 'A'; ch <= 'Z';
[Link](ch);
}
}
}
Output
Question 4
Write a program to input a set of 20 letters.
Convert each letter into upper case. Find
and display the number of vowels and
number of consonants present in the set of
given letters.
import [Link];
public class Kboat20LetterSet
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter any
int vc = 0, cc = 0;
for (int i = 0; i < 20; i++) {
char ch = [Link]().charAt
ch = [Link]
if (ch == 'A' ||
ch == 'E' ||
ch == 'I' ||
ch == 'O' ||
ch == 'U')
vc++;
else if (ch >= 'A' && ch <
cc++;
}
[Link]("Number of V
[Link]("Number of C
}
}
Output
Question 5
Write a program in Java to accept an
integer number N such that 0<N<27.
Display the corresponding letter of the
alphabet (i.e. the letter at position N).
[Hint: If N =1 then display A]
import [Link];
public class KboatInteger2Letter
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter integer
int n = [Link]();
if (n > 0 && n < 27) {
char ch = (char)(n + 64);
[Link]("Corresp
}
else {
[Link]("Please
}
}
}
Output
Question 6
Write a program to input two characters
from the keyboard. Find the difference (d)
between their ASCII codes. Display the
following messages:
If d=0 : both the characters are same.
If d<0 : first character is smaller.
If d>0 : second character is smaller.
Sample Input :
D
P
Sample Output :
d= (68-80) = -12
First character is smaller
import [Link];
public class KboatASCIIDiff
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter first c
char ch1 = [Link]().charAt(0)
[Link]("Enter second
char ch2 = [Link]().charAt(0)
int d = (int)ch1 - (int)ch2;
if (d > 0)
[Link]("Second
else if (d < 0)
[Link]("First c
else
[Link]("Both th
}
}
Output
Question 7
Write a program to input a set of any 10
integer numbers. Find the sum and product
of the numbers. Join the sum and product
to form a single number. Display the
concatenated number.
[Hint: let sum=245 and product = 1346 then
the number after joining sum and product
will be 2451346]
import [Link];
public class KboatSumProdConcat
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter 10 in
long sum = 0, prod = 1;
for (int i = 0; i < 10; i++) {
int n = [Link]();
sum += n;
prod *= n;
}
String s = [Link](sum)
long r = [Link](s);
[Link]("Concatenate
}
}
Output
Question 8
Write a menu driven program to generate
the upper case letters from Z to A and lower
case letters from 'a' to 'z' as per the user's
choice.
Enter '1' to display upper case letters from Z
to A and Enter '2' to display lower case
letters from a to z.
import [Link];
public class KboatLetters
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter '1' t
[Link]("Enter '2' t
[Link]("Enter your ch
int ch = [Link]();
int count = 0;
switch (ch) {
case 1:
for (int i = 90; i > 64; i
char c = (char)i;
[Link](c);
[Link](" ");
count++;
//Print 10 characters p
if (count == 10) {
[Link]
count = 0;
}
}
break;
case 2:
for (int i = 97; i < 123; i
char c = (char)i;
[Link](c);
[Link](" ");
count++;
//Print 10 characters p
if (count == 10) {
[Link]
count = 0;
}
}
break;
default:
[Link]("Incorre
}
}
}
Output
Question 9
Write a program to input a letter. Find its
ASCII code. Reverse the ASCII code and
display the equivalent character.
Sample Input: Y
Sample Output: ASCII Code = 89
Reverse the code = 98
Equivalent character: b
import [Link];
public class KboatASCIIReverse
{
public static void main(String args
Scanner in = new Scanner(System
[Link]("Enter a letter
char l = [Link]().charAt(0);
int a = (int)l;
[Link]("ASCII Code
int r = 0;
while (a > 0) {
int digit = a % 10;
r = r * 10 + digit;
a /= 10;
}
[Link]("Reversed Cod
[Link]("Equivalent c
}
}
Output
Question 10
Write a menu driven program to display
(i) first five upper case letters
(ii) last five lower case letters as per the
user's choice.
Enter '1' to display upper case letters and
enter '2' to display lower case letters.
import [Link];
public class KboatMenuUpLowCase
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter '1' t
[Link]("Enter '2' t
[Link]("Enter your ch
int ch = [Link]();
switch (ch) {
case 1:
for (int i = 65; i <= 69; i
[Link]((cha
break;
case 2:
for (int i = 118; i <= 122
[Link]((cha
break;
default:
break;
}
}
}
Output
Question 11
Using switch case statement, write a menu
driven program to perform the following
tasks:
(a) To generate and print the letters from A
to Z along with their Unicode.
Letters Unicode
A 65
B 66
..... ........
..... ........
Z 90
(b) To generate and print the letters from z
to a along with their Unicode.
Letters Unicode
z 122
y 121
..... ........
..... ........
a 97
import [Link];
public class KboatLettersNUnicode
{
public static void main(String arg
Scanner in = new Scanner(System
[Link]("Enter 1 for
[Link]("Enter 2 for
[Link]("Enter your ch
int ch = [Link]();
switch (ch) {
case 1:
[Link]("Let
for(int i = 65; i <= 90
[Link]
break;
case 2:
[Link]("Let
for (int i = 122; i >=
[Link]
break;
default:
[Link]("Inc
}
}
}
Output
Question 12
Write a program in Java to display the
following patterns:
(i)
A
ab
ABC
abcd
ABCDE
public class KboatPattern
{
public static void main(String arg
for (int i = 65; i < 70; i++)
for (int j = 65; j <= i; j
if (i % 2 == 0)
[Link]((c
else
[Link]((c
}
[Link]();
}
}
}
Output
(ii)
ZYXWU
ZYXW
ZYX
ZY
Z
public class KboatPattern
{
public static void main(String arg
for (int i = 86; i <= 90; i++)
for (int j = 90; j >= i; j
[Link]((char
}
[Link]();
}
}
}
Output
(iii)
ABCDE
ABC
A
public class KboatPattern
{
public static void main(String arg
for (int i = 69; i >= 65; i =
for (int j = 65; j <= i; j
[Link]((char
}
[Link]();
}
}
}
Output
(iv)
PRTV
PRT
PR
P
public class KboatPattern
{
public static void main(String arg
for (int i = 86; i >= 80; i =
for (int j = 80; j <= i; j
[Link]((char
}
[Link]();
}
}
}
Output
(v)
A*B*C*D*E*
A*B*C*D*
A*B*C*
A*B*
A*
public class KboatPattern
{
public static void main(String arg
for(int i = 69; i >= 65; i--)
for (int j = 65; j <= i; j
[Link]((char
}
[Link]();
}
}
}
Output
(vi)
aaaaa
bbbbb
AAAAA
BBBBB
public class KboatPattern
{
public static void main(String arg
int a = 97;
for (int i = 1; i <= 4; i++) {
for (int j = 1; j <= 5; j+
[Link]((char
}
a++;
if (i == 2)
a = 65;
[Link]();
}
}
}
Output
Prev Next
Case Study based questions fro… Arrays
ICSE/ISC TEXTBOOK SOLUTIONS STUDYLIST COMPANY
Class - 6 Concise Biology Selina Solutions Java Pattern Programs About Us
Class - 6 Veena Bhargava Geography Solutions Java Series Programs Contact Us
Class - 6 Effective History & Civics Solutions Java Number Programs (ICSE Classes 9 / 10) Privacy Policy
Class - 6 APC Understanding Computers Solutions Java Number Programs (ISC Classes 11 / 12) Terms of Service
Class - 7 Concise Physics Selina Solutions Output Questions for Class 10 ICSE Computer Applications
Class - 7 Concise Chemistry Selina Solutions Algorithms & Flowcharts for ICSE Computers
Class - 7 Dalal Simplified Middle School Chemistry Solutions ICSE Class 8 Computers Differentiate Between the Following
Class - 7 Concise Biology Selina Solutions CBSE TEXTBOOK SOLUTIONS
Class - 7 Living Science Biology Ratna Sagar Solutions Class - 8 NCERT Science Solutions
Class - 7 Around the World Geography Solutions Class - 9 NCERT Science Solutions
Class - 7 Veena Bhargava Geography Solutions Class - 9 NCERT Geography Contemporary India 1 Solutions
Class - 7 Effective History & Civics Solutions Class - 9 Sumita Arora Computer Code 165 Solutions
Class - 7 APC Understanding Computers Solutions Class - 9 Kips Cyber Beans Computer Code 165 Solutions
Class - 8 Concise Physics Selina Solutions Class - 10 NCERT Mathematics Solutions
Class - 8 Concise Chemistry Selina Solutions Class - 10 NCERT Science Solutions
Class - 8 Dalal Simplified Middle School Chemistry Solutions Class - 10 NCERT Geography Contemporary India 2 Solutions
Class - 8 Concise Biology Selina Solutions Class - 10 NCERT History India & Contemporary World 2 Solutions
Class - 8 Living Science Biology Ratna Sagar Solutions Class - 10 Sumita Arora Computer Code 165 Solutions
Class - 8 Around the World Geography Solutions Class - 10 Kips Cyber Beans Computer Code 165 Solutions
Class - 8 Veena Bhargava Geography Solutions Class - 11 CBSE Sumita Arora Python Solutions
Class - 8 Effective History & Civics Solutions Class - 12 CBSE Sumita Arora Python Solutions
Class - 8 APC Understanding Computers Solutions Class - 12 NCERT Computer Science Solutions
Class - 8 Kips Logix Computers Solutions
Class - 9 Concise Physics Selina Solutions
Class - 9 Concise Chemistry Selina Solutions
Class - 9 Dalal Simplified ICSE Chemistry Solutions
Class - 9 Concise Biology Selina Solutions
Class - 9 Total Geography Morning Star Solutions
Class - 9 Veena Bhargava Geography Solutions
Class - 9 Total History & Civics Solutions
Class - 9 APC Understanding Computers Solutions
Class - 9 Kips Logix Computers Solutions
Class - 10 ML Aggarwal Mathematics Solutions
Class - 10 Concise Physics Selina Solutions
Class - 10 Concise Chemistry Selina Solutions
Class - 10 Dalal Simplified ICSE Chemistry Solutions
Class - 10 Concise Biology Selina Solutions
Class - 10 Total Geography Morning Star Solutions
Class - 10 Veena Bhargava Geography Solutions
Class - 10 Total History & Civics Solutions
Class - 10 APC Modern History & Civics Solutions
Class - 10 APC Understanding Computers Solutions
Class - 10 Sumita Arora ICSE Computers Solutions
Class - 10 Kips Logix Computers Solutions
Class - 11 APC Understanding Computers Solutions
Class - 12 APC Understanding Computers Solutions
ICSE/ISC SOLVED QUESTION PAPERS
ICSE Class 10 Computers Solved 10 Yrs Question Papers
Sample Papers ICSE Class 10 Computer Applications
ICSE Class 10 Physics Solved 10 Yrs Question Papers
Sample Papers ICSE Class 10 Physics
ICSE Class 10 Chemistry Solved 10 Yrs Question Papers
Sample Papers ICSE Class 10 Chemistry
ICSE Class 10 Biology Solved 10 Yrs Question Papers
Sample Papers ICSE Class 10 Biology
Class - 12 ISC Computer Science Solved Practical Papers
Class - 10 CBSE Computer Applications Solved Question Papers
Class - 10 CBSE Computer Applications Solved Sample Papers
Class - 10 CBSE Science Solved Question Papers
Class - 12 CBSE Computer Science Solved Question Papers
Copyright © KnowledgeBoat 2024