Question
Q1. Which of the following should be defined as a void method? A.Write a method that checks whether a number is from 1 to 100.
Q1. Which of the following should be defined as a void method?
A.Write a method that checks whether a number is from 1 to 100.
B.Write a method that prints integers from 1 to 100.
C.Write a method that returns a random integer from 1 to 100
D.Write a method that converts an uppercase letter to lowercase.
Q2. You should fill in the blank in the following code with ______________.
public class Test {
public static void main(String[] args) {
System.out.print("The grade is ");
printGrade(78.5);
System.out.print("The grade is ");
printGrade(59.5);
}
public static __________ printGrade(double score) {
if (score >= 90.0) {
System.out.println('A');
}
else if (score >= 80.0) {
System.out.println('B');
}
else if (score >= 70.0) {
System.out.println('C');
}
else if (score >= 60.0) {
System.out.println('D');
}
else {
System.out.println('F');
}
}
}
options:
A.void
B.char
C.int
D.boolean
E.double
Q3.
What is the output of the following code?
public class Test5 {
public static void main(String[] args) {
int[][] matrix =
{1, 2, 3, 4},
{4, 5, 6, 7},
{8, 9, 10, 11},
{12, 13, 14, 15};
for (int i = 0; i < 4; i++)
System.out.print(matrix[1][i] + " ");
}
}
options:
A.3 6 10 14
B.1 2 3 4
C.4 5 6 7
D.1 3 8 12
E.2 5 9 13
Q4.
which of the followings are the characteristics of static methods
options:
A.can have their own local variables
B.can call only static methods
C.can access both static and instance variables
D.can access only static attributes
Q5. What will be the output of the following code
String s;
System.out.println(s);
options:
A.null
B.0
C.\u000
D.0.0
Q6.
what is the difference between pass by reference and pass by value
options:
A.in pass by value only the value of argument is sent to the method whereas in pass by reference the reference of the object is passed
B.pass by value is only applicable to integer parameters
C.both are the same
Q7.
A class can have multiple overloaded methods but it cannot have overloaded constructors
options:
True
False
NOTE: PLEASE ANSWER ONLY THE QUESTIONS YOU ARE COMPLETELY SURE ABOUT.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started