Professional Documents
Culture Documents
Question 1
d) Arrange the operators given below in order of lower precedence to higher precedence:
i) || ii) ++ iii) % iv) ( )
Question 2
1) Abstraction
2) Inheritance
3) Polymorphism
4) Function
1) True
2) false
3) 0
4) 1
1) Relational
2) Logical
3) Arithmetic
4) Increment
1) Operators
2) Separators
3) Escape sequence
int i=5;
while(i<=8)
{
System.out.print(i+ “ “);
i++;
break;
}
System.out.println(i);
1) 5 4
2) 5 6
3) 5 5
4) None of the above
{
i++;
System.out.print(i + " " );
}
System.out.print(i);
1) 3 5 7 9 10
2) 5 7 9 10
3) 3579
4) 5 7 9 10 11
1) 14 13
2) 13 13
3) 12 13
4) 13 14
Question 4
a) If (( -7 >-9) | | (12<=10))
1) True
2) False
1) Value of S is 10
2) Value of S is 0
3) Value of S is 2
c) switch (cc)
{
case 4: System.out.print(“SEMESTER”);
case 7: System.out.print(“2021”);
break;
}
Where cc=4;
1) SEMESTER
2) SEMESTER EXAMINATION
3) SEMESTER EXAMINATION 2021
4) 2021
1) 72
2) 74
3) 73
4) None of the above
Question 5
1) FOUR TWO 42
Four 22
2) FOUR TWO42four4
b) A java statement to define the variable name “charge” as constant of double data type
having value 33.24.
1) float charge = 33.24;
2) const double charge= 33.24;
3) final Double charge= 33.24;
4) final double charge= 33.24;
e) double x = Math.abs(Math.ceil(-6.39));
1) -6.00
2) 6.00
3) -7.00
4) 7.00
Question 6
The following program is based on the specification as given below. Fill in the blanks with
appropriate java statements.
Instance variables/data members:
int days – to store the number of days the bike is taken on rent
int charge – to calculate and store the rental charge
Member methods:
void input( ) – to input and store the detail of the customer.
void computer( ) – to compute the rental charge.
The rent for a motorbike is charged on the following basis.
First five days Rs 500 per day;
Next five days Rs 400 per day
Rest of the days Rs 200 per day
void input ( )
{
Scanner obj= new Scanner(System.in);
System.out.println(“ ENTER NUMBER OF DAYS “);
days= ____1_____ = nextInt( );
}
void compute ( )
{
if ( 2 )
charge= 500 * days;
else
charge= _______5___________;
}
void display( )
{
System.out.println(“ NUMBER OF DAYS THE BIKE IS RENTED IS “ +days);
System.out.println(“ THE CHARGE IS “ +charge);
}
1) [1]
a) sc
b) obj
c) ob
d) scan
2) [1]
a) days<4
b) days<=5
c) days <6
d) days <3
3) [1]
a) 2500+(days-4) * 400;
b) 2000+(days -5 ) * 400;
c) 2500 +(days – 5)* 400
d) None of the above
5) [1]
a) 2500 + 2000+ (days-10) *200;
b) 250 + 2000+ (days-10) *200;
c) 2500 + 2000+ (days-9) *200;
d) None of the above
Question 7
Instance variables:
intro;
String name;
Member methods:
class (1)_________________
{
intro;
String name;
Student(int roll )
{
____2_ = roll;
name=” ROHIT”;
}
}
void print( )
{
System.out.println(“ ROLL IS “ +roll + “\t “ +”NAME IS “ + name);
}
public static void main(String args [ ])
{
Studentob = new __________4;
ob. _____5____;
Student ob1= new Student(33,” RITAM”);
ob1.print( );
}
}
1) [1]
a) Student
b) Students
c) student
2) [1]
a) lroll
b) ro
c) roll.l
3) [1]
a) this.ro
b) this.ROLL
c) roll
4) [1]
a) Student(7);
b) Student(21.6,4.6);
c) Area (44)
5) [1]
a) print( );
b) Prints( );
Given below are the methods defined inside a single class with the following specification:
i) double area (int a , int b, int height) – with three integer arguments , returns the area of a
trapezium using the formula:
area= 0.5 * height * (a+b)
ii) void area1 (double diagonal1 , double diagonal2) – with two double arguments , returns the area
of a rhombus using the formula:
area = 0.5 *( diagonal1 * diagonal2)
Create a main method to call the above defined methods.
class Calculate
{
}
void area (double diagonal1 , double diagonal2)
{
2) [1]
a) d1 *d2
b) diagonal1 * diagonal2
c) diagonal1 / diagonal2
3) [1]
a) Calculate
b) Calculation
c) Calculating
4) [1]
5) [1]
a) Area
b) area
Question 9
The following program is written to input a number and check and print whether it is a
Pronic number or not. (Pronic number is the number which is the product of two
consecutive integers)
Examples : 12 = 3 × 4 .
20 = 4 × 5
42 = 6 × 7
a) Scanner
b) BufferedReader
c) Scan
d) Scans
2) [1]
a) nextint( );
b) nextInt( );
c) nextInteger( );
3) [1]
a) i
b) i + (i + 1)
c) x
4) [1]
a) i*(i+1)
b) i+(i*1)
c) i+1
5) [1]
a) else
b) else if
c) if
--------------------------------------------------------------------------------------------------------------------