0% found this document useful (0 votes)
27 views

Class Test Class 10 MM-50 SESSION-2021-22: Section-A (30 Marks)

1. The document contains a class test with 5 questions and 20 marks for section A and 2 questions for section B with 20 marks. 2. The questions are multiple choice, fill in the blanks and writing code-based questions to test concepts of classes, methods, functions, data types, loops and conditional statements in Java. 3. The document provides sample inputs and outputs to describe the expected behavior of programs to be written by students as part of the test.

Uploaded by

Lena Albert
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Class Test Class 10 MM-50 SESSION-2021-22: Section-A (30 Marks)

1. The document contains a class test with 5 questions and 20 marks for section A and 2 questions for section B with 20 marks. 2. The questions are multiple choice, fill in the blanks and writing code-based questions to test concepts of classes, methods, functions, data types, loops and conditional statements in Java. 3. The document provides sample inputs and outputs to describe the expected behavior of programs to be written by students as part of the test.

Uploaded by

Lena Albert
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Class test

Class 10th
MM-50
SESSION-2021-22
SECTION-A(30 MARKS)

Question 1
Choose the correct answer

(a) If a class Programmer acquires its properties from class Employee, then
Programmer and Employee are known as ______ class and ________
class respectively.

1. Data members and Functions


2. Objects and class
3. Real world class and software class
4. None of these
Answer: None of these
(b) Which of the following is smallest integer data type?

1. short
2. Byte
3. byte
4. bit
Answer: byte
(c) Suppose num1 and num2 are two double type variables that you want to
add as an integer form and assign to a variable res of type int. Choose the
correct statement for given task.

1. res = (int) (num1+num2);


2. res = num1+num2;
3. res = (double) num1+num2;
4. res = (long) num1+num2;
Answer: res = (int) (num1+num2);
(d)What is the final value stored in variable c?
double a = -6.52;
double b = -14.74;
int c = (int) Math.round(Math.max(a,b));

1. -6
2. -6.0
3. -7
4. -7.0
Answer: -7

(e) Which of the following are valid identifiers?


(i) Games
(ii) flag
(iii) INCOME_TAX
(iv) Break

1. (i) & (iii)


2. (iii) & (iv)
3. All of the above
4. None of the above
Answer:All of the above
Question 2
Fill in the blanks with the correct option
a . A _____ function does not change or modify the state of their parameters
received.
a. pure
b impure
c actual

Answer: Pure

(b) if((a<b)&&(a>c)) then ______ is the largest number


1. b
2. c
3. a
Answer: 1. b

(C) A software method is referred to as __________of real world object.


1. FUNCTION
2. MEMBER FUNCTION
3.CHARACTERISTICS
4.BEHAVIOUR
Answer: Behaviour
(D) For each of the primitives types there is a corresponding _______ method
that returns a value of that type.
1. sqrt( )
2.readLine( )
3. parseInt( )
4. nextXxx( )
Answer: nextXxx( )

(E) Two things ______ and _____ should be done while creating a function
1. data members and member function
2. static function and non static function
3. function header and block
4. function definition and function call
Answer:function definition and function call

Question 3
Name the following

a) Only _______ are created for every objects

1. new
2. instance
3. instance variable
4. stack
Answer:instance variable

b) All Java components require names. Names used for classes, variables,
and methods are called?
1. Variables
2. keywords
3. Access Modifiers
4. None of these
Answer: None of these
c) Which is correct about an instance variable of type double?
A. It defaults to an empty value.
B. It defaults to 0.0
C. It does not have a default value.
D. It will not compile without initializing on the declaration line
Answer: B. It defaults to 0.0
d). Keyword which passes the control to the calling method
a. return
b. void
c. break
d.continue
Answer:return

e) The parameters appearing in function call statement are called

a) Actual parameters
b) Formal parameters
c) Call parameters
d) All of the above

Answer:Actual Parameters

Question 4
State True Or False

(a)When you need to execute more than one statement(s) based on a


condition then all the statements must be enclosed within parentheses ( )
inside if block.

1. True
2. False

(b) Math class is included in java. util


1. True
2. False

(c)Character data type cannot store String value.

1. True
2. False

(d) Condition is built using relational operator.

1. True
2. False

(e) In the absence of any other access specifier , public access takes place

1.True
2. False
Question 5
Choose the odd one [5]

a)

1. public
2. private
3. default
4. public

b)
1.//
2./* /*
3. /** */
4. /* */

c)
1.instance variable
2.local variable
3.path variable
4.class variable

d)
a. /
b.++
c. *
d. %

e)
1. void
2. int
3. boolean
4. double
Question 6
Give the output of the following

a) p=7 ,q=9,r=11
q*=5+(--q)*(q++)+10;

1.119
2.711
3.2106
4.792

b) How many time the loop is executed and what is the output?
int x = 4,y=0,z,c=0;
while(x>=0)
{
c++;
if(x==y)
break;
x--;
y++;
}
System.out.println(x+” “+y);

1. Loop is executed 3 times and the output is 2,2


2. Loop is executed 3 times and the output is 2,3
3. Loop is executed 2 times and the output is 3,2

c)
char opn = 'b';
switch(opn)
{
case 'a':
System.out.println("Platform independet");
break;
case 'b':
System.out.print("Object oriented");
case 'c':
System.out.print("Robust and secure");
default:
System.out.print("Wrong output");
}

a) Object oriented
b) Object orientedRobust and secure
c) Object orientedRobust and secureWrong output

d)
int num = 101;
if(num++==102)
System.out.println("Inside if block");
System.out.println("end of program");

a) Inside if block
b) end of Program
c) Inside if block - end of program.

e) int y,a=91;
y = a>=65 && a<=90?1:0;
System.out.println(y);

a) 1
b) 0
c) 1:0
SECTION-B(20 MARKS)

Question-7
Write a class with the name Perimeter using function overloading that computes
the perimeter of a square, a rectangle and a circle.
Formula:
Perimeter of a square
Perimeter of a rectangle
Perimeter of a circle

public class(a) ________


{
public double perimeter((b)_____)
{
double p = 4 * s;
(c) _______ ;
}
public double perimeter(double l, double b)
{
double p = (d)______;
return p;
}
public e)______ perimeter(int c, double pi, double r)
{
f)______ = c * pi * r;
return p;
}
}

a)
1.perimeter
2.Perimeter
3.Overload

b) 1.s
2.int s
3. int s;
c) 1.System.out.println(p)
2.return(p)
3.System.exit(0);

d)1. 4*s;
2.2*(l+b);
3. s*s

e)1.void
2.int
3.double

f)1. int p
2. double p
3.float p

Question 8
Define a class Electricity Bill with the following specifications:
Data Members Purpose
String n stores the name of the customer
int units stores the number of units consumed
double bill stores the amount to be paid

Member Methods Purpose

void accept() to store the name of the customer and number of units consumed
Member Methods Purpose

void calculate() to calculate the bill as per the tariff table given below

void print() to prints the details in the format given below

Tariff Table
Number of units Rate per unit
First 100 units ₹2.00
Next 200 units ₹3.00
Above 300 units ₹5.00
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
Output:
Name of the customer: _________________________
Number of units consumed: _____________________
Bill amount: ________________

public class ElectricityBill


{
String n;
______ units;
double bill;

public void accept()


{
Scanner in = (a) ________(System.in);
System.out.print("Enter customer name: ");
n = (b)_______
System.out.print("Enter units consumed: ");
units = in.nextInt();
}
public void (c)_____
{
if (units <= 100)
bill = units * 2;
else if ((d)_____)
bill = 200 + (units - 100) * 3;
else if(untis>300)
{
double amt = 200 + 600 + (units - 300) * 5;
double surcharge=(e)_______;
bill = amt + surcharge;
}
}

public void print()


{
System.out.println("Name of the customer\t\t: " + n);
System.out.println("Number of units consumed\t: " + units);
System.out.println("Bill amount\t\t\t: " + bill);
}

public static void main(String args[])


{
ElectricityBill ob = new ElectricityBill();
(f)________
ob.calculate();
ob.print();
}
}

a)1.new Scanner
2. Scanner new
3. new System.in

B)1.in.nextInt();
2.in,next().charAt(0);
3.in.nextLine();

c)1.Compute()
2. calculate()
3. calculate(int s)
d)1.units>100 | | units<=200
2.units>100&&units<=200
3.units>100&&units<=300

e)1. (amt * 2.5) / 100.0;


2. (amt*250)/10
3. (amt*2)/100;

f) 1.ob.accept();
2. accept();
3. ob.accept;

Question 9
Write a program to input a number. Use a function int Armstrong(int n) to
accept the number. The function returns 1, if the number is Armstrong,
otherwise zero(0).(Assume 3 digit number)
Sample Input: 153
Sample Output: 153 ⇒ 13 + 53 + 33 = 153

It is an Armstrong Number.

import java.util.*;
class Compute
{
public int Armstrong(int n)
{

int t1=(a)______;
(b) _______;
while((c)_____)
{
int d = t1%10;
sum = sum+(d)________;
t1 =t1/10;
}
if(sum==n)
return 1;
else
return 0;

}
public static void main()
{
Scanner sc = new Scanner(System.in);
int num,k;
System.out.println("Enter a number");
num = sc.nextInt();
Compute obj = new Compute();
k=obj.Armstrong(num);
if(k==1)
System.out.println("Number is Armstrong");
else
System.out.println("Number is not an Armstrong");
}
}

a) 1.Int n
2.n
3int n
b) 1.sum=0
2 int sum = 0
3.int sum = 0.0

c) 1. n>0
2. t1>0
3. n!=0

d) 1.d*d
2. (int)Math.pow(d,3);
3. Math.pow(digit,3);
Question 10
Sequential constructs execute a set of statements in sequential order and Selection
Constructs execute certain set of statements only if a condition is met. Iterative
statements allow a set of instructions to be executed repeatedly until a condition is met.
Java provides three kinds of looping constructs - for loop, while loop and do -while
loop. All three loops repeat a set of instructions as long as the underlying conditions
remains true. The underlying condition is termed as the test condition. The test
condition may be evaluated before the start of the loop or at the end of the loop.
Accordingly, the loop is termed as an entry-controlled loop or exit controlled loop,
respectively. Both for loop and while loop are entry-controlled loop while do while is an
exit control loop. For loop is used if you know how many times the loop will be executed
and while and do while loop is used if you don’t know how many times loops are
executed.
i. If the test condition is evaluated at the beginning of loop, it is termed as
a. Entry Control Loop
b. Exit Control Loop
c. Destructive Loop

ii. If you don’t know how many times loops are executed then we will use
a. while and for
b. while and do while
c. for and do while

iii. Java provides how many types of looping constructs


a. one
b. two
c. three
d. four

iv. The entry control loops in java are


a. for while
b for do while
c. do while while

You might also like