KnowledgeBoat Logo
OPEN IN APP

Chapter 1 - Case Study

Case Study based questions from revision of Class IX Syllabus

Class 10 - APC Understanding Computer Applications with BlueJ



Case Study based Questions

Question 1

Generally, a computer language uses either compiler or interpreter (a set of programs) to convert source code into object code. But Java, a case sensitive language, uses both the translators (i.e., compiler as well as interpreter). Firstly, compiler converts the Java source code into an intermediate code which is further converted into machine code with the help of an interpreter.

Based on the above discussion, answer the following questions:

(a) Which of the following statement is true?

  1. Java compiler is a hardware.
  2. Java compiler is a software but interpreter is a hardware.
  3. Both the translators are hardware.
  4. Both the translators are software.

(b) The intermediate code is referred to as:

  1. Byte code
  2. Assembly code
  3. ASCII code
  4. Unicode

(c) Java interpreter is also known as:

  1. Artificial machine
  2. Virtual machine
  3. Real machine
  4. Normal machine

(d) What is meant by a case sensitive language?

  1. It understands only lowercase letters.
  2. It understands only uppercase letters.
  3. It distinguishes between lowercase and uppercase letters.
  4. It doesn't distinguish between lowercase and uppercase letters.

Answer

(a) Both the translators are software.

(b) Byte code

(c) Virtual machine

(d) It distinguishes between lowercase and uppercase letters.

Question 2

An operator is basically a symbol which performs arithmetical and logical operations to yield meaningful results. There are three types of operators used to perform any operation in Java programming. They are arithmetical, relational and logical operators. The arithmetical operators are used to perform arithmetical calculations. They are unary, binary and ternary operators. The syntax of using ternary operator is:

variable = (condition) ? expression 1 : expression 2;  

Based on the above discussion, answer the following questions:

(a) A/An ............... operator works on a single operand.

  1. binary
  2. relational
  3. unary
  4. ternary

(b) Which of the following is not a logical operator?

  1. ++
  2. &&
  3. ||
  4. !

(c) Which of the following constructs is equivalent to the ternary operator in Java language?

  1. if
  2. if-else
  3. nested if
  4. switch-case

(d) Which of the following is a relational operator?

  1. &
  2. $
  3. !=
  4. !

Answer

(a) unary

(b) ++

(c) if-else

(d) !=

Question 3

Functions are the built-in modules that can be used in our program to perform a specific operation. There are some mathematical functions that are used for specific functions. For example, we can use Math.sqrt( ) function to return square root of a positive number, Math.random( ) and Math.ceil( ) to return random number in a range of numbers to return the next higher integer number.

Based on the above discussion, answer the following questions:

(a) What will be displayed, if the following statement is executed?
System.out.println(Math.sqrt(-25));

  1. Infinite
  2. -5.2
  3. NaN
  4. Logical error

(b) Math.random( ) function returns a random number in the range:

  1. between 0 and 1
  2. between -1 to 0
  3. between -1 to 1
  4. None of the above

(c) Which of the following function will return the next higher integer number?

  1. Math.max( )
  2. Math.min( )
  3. Math.floor( )
  4. Math.ceil( )

(d) Which of the following statement is true for Math.max( )?

  1. It will always result in int type value.
  2. It will always result in double type value.
  3. The resultant data type will depend upon the type of arguments.
  4. It will return float type, if arguments are double type.

Answer

(a) NaN

(b) between 0 and 1

(c) Math.ceil( )

(d) The resultant data type will depend upon the type of arguments.

Question 4

Java, like all other programming languages uses some statements that allow us to check a condition and execute certain parts of a code depending on whether the condition is true or false. Such statements are called conditional statements. We can also use a conditional statement within another conditional statement. The inner conditional statement is executed only when the outer condition is true. The conditional statement can also be a multiple branching statement.

Based on the above discussion, answer the following questions:

(a) Which of the following is not a decision making statement?

  1. if - else
  2. if
  3. break
  4. if-else-if

(b) A conditional statement used within another conditional statement is known as ...............

  1. nested conditional statement
  2. embedded conditional statement
  3. accumulated conditional statement
  4. None of the above

(c) Which of the following is called as multiple branching statement?

  1. if and only if
  2. switch
  3. control
  4. shift

(d) Which of the following is not a component of multiple branching statement?

  1. break
  2. default
  3. case
  4. pause

Answer

(a) break

(b) nested conditional statement

(c) switch

(d) pause

Question 5

The following program segment calculates the norm of a number. The norm of a number is the square root of sum of squares of all the digits of the number.
Sample Input: 68
Sample Output: The norm of 68 is 10
[Hint: 6x6 + 8x8 = 36 + 64 = 100
The square root of 100 is 10. Hence, norm of 68 is 10]
There are some places in the program left blank marked with ?1?, ?2?, ?3? and ?4? to be filled with variable/function/expression.

Scanner in = new Scanner(System.in);
int num;
int d, s = 0;
num = ......?1?...... 	
while (......?2?......)
{
    d = num % 10;
    s = ......?3?......
    num = num / 10;
}
System.out.println("The norm of " + num + " is " + ......?4?......);

Based on the above discussion, answer the following questions:

(a) Which of the following will be filled in place of ?1?

  1. in.nextInteger;
  2. in.NextInt( );
  3. in.nextInt( );
  4. in.nextint( );

(b) What will you fill in place of ?2?

  1. num > 0
  2. num < 0
  3. num > 1
  4. num = 0

(c) What will you fill in place of ?3?

  1. s + d * d
  2. s * d + d
  3. s * s + d
  4. s + d

(d) What will you fill in place of ?4?

  1. Math.sqrt(s)
  2. Math.SQRT(s)
  3. Math.sqrt(n)
  4. Math.sqrt(num)

Answer

(a) in.nextInt( );

(b) num > 0

(c) s + d * d

(d) Math.sqrt(s)

The completed program is given below for reference:

Scanner in = new Scanner(System.in);
int num;
int d, s = 0;
num = in.nextInt( ); 	
while (num > 0)
{
    d = num % 10;
    s = s + d * d;
    num = num / 10;
}
System.out.println("The norm of " + num + " is " + Math.sqrt(s));
PrevNext