Prashnikaप्रश्निका
Code
About
Computer ScienceClass 12

Primitive values, Wrapper classes, Types and casting - ISC Class 12 Computer Science Questions with Answers

11 past-paper questions on Primitive values, Wrapper classes, Types and casting from ISC Class 12 Computer Science papers (2025-2018), newest first, in full. Tap "Show answer" under a question to see its answer. The syllabus covers Primitive values and types, Wrapper classes, Class as user defined type and Type casting and coercion.

11questions
3years
2025newest
20258 questions
1 mark · Case basedOpen: Ram and Hari are coder friends, who are debating effective usage of memory…

Answer the following questions.

Ram and Hari are coder friends, who are debating effective usage of memory while using variables, without compromising on precision of values. Help them on identifying the right data type to use, for the following data:
(a)[0.5]
Population of a country
(b)[0.5]
Interest rate in a bank account
Show answer

Answer (a)

long (a population count can exceed the range of int, so a larger integer type is used).

Answer (b)

float (a decimal value where double's extra precision is not needed, saving memory).
1 mark · Short answerOpen: Since a byte can represent 256 different numbers, why is its maximum value 127?

Answer the following question.

Since a byte can represent 256 different numbers, why is its maximum value 127?
Show answer

Answer

A byte is stored in two's complement (signed) form, so one bit is used as the sign bit, not for magnitude. Of the 256 possible bit patterns, half (128) represent negative numbers (-128 to -1) and the other half represent zero and positive numbers (0 to 127), so the maximum positive value it can hold is 127.
1 mark · Short answerOpen: Teachers of class XII are calculating the average attendance for 3 months. The…

Answer the following question.

Teachers of class XII are calculating the average attendance for 3 months. The class attendance for 3 months is stored in double variables m1, m2, m3. TeacherA and TeacherB are using different techniques to get the average. Complete the code of TeacherA and name the technique used by him:
TeacherATeacherB
int average = (____)((m1+m2+m3)/3);int average = Math.round((m1+m2+m3)/3);
Show answer

Answer

int average = (int)((m1+m2+m3)/3); TeacherA uses type casting (narrowing/explicit type conversion) - it truncates the decimal part, while TeacherB's Math.round() rounds off the value to the nearest integer.
1 mark · Fill inOpen: Following is a code to convert a String into Double. Fill the missing parts of…

Fill in the blanks marked ?1?, ?2? ... so that the code works.

Following is a code to convert a String into Double. Fill the missing parts of the code:
____ str = "15.45"; 
double d = ____ (Double.parseDouble(str));
Show answer

Answer

Blanks: String; (double)

The first blank is the type of the variable holding the text, so it is String. The second blank is a type cast to double. Double.parseDouble(str) already returns a double, so the cast is harmless:
String str = "15.45";
double d = (double) (Double.parseDouble(str));
d now holds 15.45.
1 mark · Short answerOpen: While using Wrapper classes, we do not need to import any package. Give a…

Answer the following question.

While using Wrapper classes, we do not need to import any package. Give a reason.
Show answer

Answer

Wrapper classes belong to the java.lang package, and java.lang is imported into every Java program automatically by the compiler, so no explicit import statement is needed to use them.
1 mark · OutputOpen: What gets printed? char [ ] set = {'*','D','5'}…

What is the output of the following code?

What gets printed?
char [ ] set = {'*','D','5'}; 
System.out.print(Character.isDigit(set[2]) + " "); 
System.out.print(Character.isWhitespace(set[0]) + " "); 
System.out.print(Character.isLetterOrDigit(set[1]));
Show answer

Answer

true false true
20222 questions
2 marks · MCQOpen: What is the output of the statement given below?…

Choose the correct option.

What is the output of the statement given below?
System.out.print(Integer.parseInt("234") + 'A');
  • (a)234+65
  • (b)234A
  • (c)299
  • (d)ERROR
Show answer

Answer

Correct option: (c)

Answer: (c) 299 Integer.parseInt("234") is the int 234 and 'A' is 65, so the sum 299 is printed.
20181 question
2 marks · Short answerOpen: What are Wrapper classes? Give any two examples.

Answer the following.

What are Wrapper classes? Give any two examples.
Show answer

Answer

Wrapper classes are classes provided by Java that 'wrap' (encapsulate) a primitive data type inside an object, so that a primitive value can be treated as an object (e.g. for use in collections, or to access utility methods such as converting/parsing strings to numbers). Every primitive type has a corresponding wrapper class. Examples: Integer (wraps int), Character (wraps char) - (any two, e.g. Double for double, Boolean for boolean, are equally acceptable).

About Primitive values, Wrapper classes, Types and casting

Primitive values, Wrapper classes, Types and casting is a unit of the ISC Class 12 Computer Science syllabus.

The syllabus lists these topics: Primitive values and types, Wrapper classes, Class as user defined type and Type casting and coercion.

Prashnika has 11 past-paper questions on Primitive values, Wrapper classes, Types and casting, from papers of 2018-2025, asked in 3 different years. By kind: Short answer (6), MCQ (2), Case based (1) and Fill in (1). They carry between 1 and 2 marks, and most are worth 1 mark.

To practise, use the paper generator, which can build a practice paper from this chapter.

Common questions

What topics are in Primitive values, Wrapper classes, Types and casting in ISC Class 12 Computer Science?

The syllabus lists Primitive values and types, Wrapper classes, Class as user defined type and Type casting and coercion.

How many questions on Primitive values, Wrapper classes, Types and casting are in ISC Class 12 Computer Science past papers?

Prashnika has 11 questions on Primitive values, Wrapper classes, Types and casting, from papers of 2018-2025 (board, specimen, improvement and practice papers together).

What kinds of questions are asked on Primitive values, Wrapper classes, Types and casting?

By kind: Short answer (6), MCQ (2), Case based (1) and Fill in (1).