Answer to Question #108202 in Java | JSP | JSF for Lavi

Question #108202
Question 1. Write True or False for each of the following statements.(corecct if fales)
1-If a method does not return a value, the return value type must be static.
2-The expression !(true || true && false || !true) is evaluated to true.
3-Every array has a length that specifies the number of elements in the array.
4-It is possible for the body of a do-while statement to never be executed.
5-The statement import java.*.*; is valid if placed at the very top of a Java source file.
6-The expression s.indexOf(",") returns the position of a comma in s, a String object.
7-The following statement System.out.print("Hi".compareTo("Hi") == 0); is correct.
8-The switch selection structure must end with the default case.
9-Variables declared in the body of a particular method are known as local variables.
10-int array = new int[10]; creates an integer array of size 10
1
Expert's answer
2020-04-07T09:03:27-0400

1-If a method does not return a value, the return value type must be static.

Answer: false

If a method does not return a value, the return value type must be void.

2-The expression !(true || true && false || !true) is evaluated to true.

Answer: false

The expression !((true || true) && (false || !true)) is evaluated to true

3-Every array has a length that specifies the number of elements in the array.

Answer: false

Array has length only after definition (int [ ] a = new int [10];) and length its not a number of elements in array its capacity.

4-It is possible for the body of a do-while statement to never be executed.

Answer: false

Do-while statement always executes at least one time because of the logic: do something and then check.

5-The statement import java.*.*; is valid if placed at the very top of a Java source file.

Answer: false

This is a wrong design, the first * means that all packages have already been imported, so using the second * is wrong, but even using the first * in this case is an error, since such an import can lead to errors, because the packages may contain classes with the same names and the compiler will not be able to understand which classes should be used.

6-The expression s.indexOf(",") returns the position of a comma in s, a String object.

Answer: true

7-The following statement System.out.print("Hi".compareTo("Hi") == 0); is correct.

Answer: true

8-The switch selection structure must end with the default case.

Answer: false

The default case is an optional case.

9-Variables declared in the body of a particular method are known as local variables.

Answer: true

10-int array = new int[10]; creates an integer array of size 10

Answer: false

int [ ] array = new int[10]


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS