Final Test-IX
Final Test-IX
Final Test
Full Marks: 100. Time: 2hrs.
SECTION A (20 MARKS) ANSWER ALL QUESTIONS
Question 1(Chose the correct alternative) 1X20
i) Which among the following is a valid float literal?
a. 12.36f b. 12.36F c. 12.36 d. Both a and b
ii) Name the characteristics of Object Oriented Programming that hides the complexity and provides a
simple interface.
a. Encapsulation b. Polymorphism c. Abstraction d. Inheritance
iii) An object is represented by two attributes, out of which one is characteristics and the other one is_____.
a. Behaviour b. Situation c. Abstraction d. Encapsulation
iv) Which among the following is used to represent single-line comment?
a. // b. /* c. \\ d. <!—
v) Which among the following represents a syntax error?
a. Dividing an integer by zero. b. Accessing an element that is out of bounds of an array.
c. Trying to store a value which is incompatible to a certain data-type. d. Missing semicolon
vi) Which among the following Scanner methods allows us to input a number with a decimal point?
a. nextInt() b. nextFloat() c. nextDecimal() d. nextPoint()
vii) Which among the following is not a logical operator?
a. && b. || c. ! d. <=
viii) Name the process that converts source code to bytecode.
a. Interpretation b. Compilation c. All of these d. None of these
ix) A Virtual Processor that is implemented in software and runs using the capabilities provided by your
operating system and computer hardware.
a. Byte Code b. Compiler c. Interpreter d. Java Virtual Machine(JVM)
x) What is the extension of the byte code in Java?
a. .java b. .class c. Both a and b d. None of these
xi) Which among the following is a valid object name?
a. obj1 b. 1obj c. Obj 1 d. Obj#1
xii) Which among the following is not a Token?
a. Keywords b. Literals c. Identifiers d. Data Type
xiii) Which among the following is a valid method of initialising?
a. boolean f=true; b. boolean f=True; c. boolean f=’true’; d. None of these
xiv) If a is of type int and b is of type float what would be the resultant data type of a+b?
a. int b. float c. double d. short
xv) Which among the following is a relational operator?
a.+ b. > c. * d. /
xvi) Which among the following operators is used to dynamically allocate memory space for an object?
a. . (dot) b. > c. == d. new
xvii) Which among the following package is imported by default:
a. java.lang b. java.util c. Both a and b d. None of these
xviii) Which among the following function returns the absolute value of a number?
a. Math.absoulute( ) b. Math.neutral( ) c. Math.abs( ) d. Math.positive( )
xix) Which among the following gives the next mathematical integer?
a. Math.floor( ) b. Math.ceil( ) c. Math.random( ) d. All of these
xx) Which among the following constants are used in switch-case statements?
a. char b. Int c. float d. Both a and b
SECTION B (20 MARKS) ANSWER ALL QUESTIONS
Question 2 2X10
i) Write a program to calculate the charge of a transport company according to the following criteria:
Weight Rate
Upto first 100 Kg Rs. 10/Km
For the next 50 Kg Rs. 7/Km
Above 150 Kg Rs. 5/km
Display the details in the following format:
Weight Kilometer travelled Total cost
_______ _____________ _________
ii) Write a program to input a number and check whether it is a prime number or not. (A prime number is
one which has two factors 1 and the number itself).
iv) Write a program to input the radius of a circle, length and breadth of a rectangle, side of a square and a
choice. lf choice is 1 calculate and print the area of a circle (3.14*radius*radius), if choice is 2 calculate
and print the area of a square (side*side), if choice is 3 calculate and print the area of a
rectangle(length*breadth).
v) Write a program in java to print details of an employee for the following specification:
vi) Write a program in java to accept a number from the user and print its last digit in words.
Example: Enter – 267 Output – Seven
-------------------------------------------------------END-----------------------------------------------------