Class Test Class 10 MM-50 SESSION-2021-22: Section-A (30 Marks)
Class Test Class 10 MM-50 SESSION-2021-22: Section-A (30 Marks)
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. 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. -6
2. -6.0
3. -7
4. -7.0
Answer: -7
Answer: Pure
(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
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
a) Actual parameters
b) Formal parameters
c) Call parameters
d) All of the above
Answer:Actual Parameters
Question 4
State True Or False
1. True
2. False
1. True
2. False
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);
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
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
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
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: ________________
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
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