9th computer
Section A
Question 1
-
Which of these is not a Java keyword?
a) class b) new c) then d) void -
Which operator is used for division in Java?
a) ÷ b) div c) / d) % -
Which data type can store true/false values in Java?
a) int b) boolean c) char d) String -
Which of these is the correct way to declare an array of 5 integers?
a) int arr[5]; b) int arr = new int[5]; c) int arr[ ] = new int[5]; d) int[5] arr; -
Which method of Scanner is used to read a floating-point number?
a) nextFloat() b) readFloat() c) getFloat() d) float() -
Which access modifier makes members visible everywhere?
a) private b) protected c) public d) default -
Which of the following is a wrapper class in Java?
a) int b) char c) Integer d) String -
Which package is imported automatically in every Java program?
a) java.io b) java.lang c) java.util d) java.net -
Which operator is used for logical OR in Java?
a) || b) or c) | d) + -
Which of these is not an arithmetic operator?
a) + b) - c) * d) && -
Which keyword is used to create an object in Java?
a) object b) class c) new d) this -
Which operator is used to check if two objects are equal in content?
a) == b) = c) equals() d) := -
Which type casting is also called “type promotion”?
a) Narrowing b) Explicit c) Widening d) Manual -
What will be the result of 15 / 4 in Java?
a) 3.75 b) 3 c) 4 d) 15 -
What is the default value of an int variable in Java?
a) 0 b) null c) garbage d) 1 -
Which of these is not a valid identifier in Java?
a) myNumber b) _value c) 123num d) total -
Which keyword is used to stop the execution of a loop?
a) exit b) break c) stop d) continue -
Which is the correct way to declare a constant PI with value 3.14?
a) const double PI = 3.14; b) double PI = 3.14; c) final double PI = 3.14; d) constant PI = 3.14; -
Which method of Scanner is used to read a single word?
a) nextWord() b) next() c) get() d) read() -
Which of the following is not an OOP principle?
a) Polymorphism b) Abstraction c) Compilation d) Encapsulation
Question 2
-
Write a Java statement to declare an integer variable named age and assign it the value 18.
-
Differentiate between while loop and do-while loop.
-
Which Scanner method is used to read a long value from the user?
a) nextLong() b) readLong() c) getLong() d) long() -
Name two data types in Java that can store whole numbers.
-
Write the syntax to read a double value from the user using the Scanner class.
-
Which keyword is used to define a class in Java? Give an example.
-
What will be the output of the following code?
int a = 10; a -= 4; System.out.println(a);
a) 14 b) 6 c) 4 d) 10
-
Write the output of
Math.min(25, 40)
andMath.abs(-12)
. -
Which OOP pillar allows using the same method name but with different parameters?
a) Abstraction b) Inheritance c) Polymorphism d) Encapsulation -
What is the output of the following code?
int a = 5; int b = a++; System.out.println(b);
a) 5 b) 6 c) 4 d) Error
Section B
Question 3
a) Write a program to calculate the area and circumference of a circle.
b) Write a program to calculate the perimeter of a rectangle.
Question 4
Write a program to input three numbers and display the largest and smallest among them.
Question 5
a) Write a program to demonstrate the use of logical operators (&&
, ||
, !
).
b) Write a program to demonstrate the use of relational operators (<
, >
, ==
, !=
).
Question 6
Write a program to input the marks of 5 subjects and display the total marks and percentage.
Question 7
a) Write a program to convert temperature from Fahrenheit to Celsius.
b) Write a program to find the square root of a number using Math.sqrt()
.
Question 8
Write a program to calculate compound interest based on user input for principal, rate, and time.
π Do you want me to now create a third full set of such questions with options (so you have multiple practice papers ready)?
Comments
Post a Comment