Java Level 1 Exam Questions
Java Level 1 Exam Questions
1. Indicate what the result of the expression in bold would be considering the value
from the variables a, b, c, d, and e that appear below:
int a = 3; int b
=5; int c = 4;
boolean d =
false; boolean e
= false;
(a+b-c < c ) || (d || e)
a) true
b) false.
c) 4
3. An algorithm is:
a) A series of organized steps that describe the process to follow to solve a problem
specific
b) A set of rules that can be applied in each of the states of a problem to
moving towards the solution
c) The sequence of instructions to optimally solve a problem
4. Indicate whether the following statements are true, and briefly explain why.
a) "It is possible for objects belonging to the same class to have attributes that have the same
value for all and that they change in all when one changes.
b) "Inheriting from a class that in turn inherits from another is considered multiple inheritance and is
forbidden in Java. (Example: class A inherits from B and class B inherits from C)
5. Given the following Java code:
public void method1(int number) {
[Link]();
}
}
7. Indicate whether the assignment that appears in the following Java code is correct or not and correct it.
in case it is not. Indicate what the value stored in the variable d would be as a result of
the assignment:
8. Proceed in the same way for the following code, indicating what value would be stored in the
variable i:
9. The assignment that appears below is incorrect. Indicate how to correct it so that the
the value stored in i should be as close as possible to the mathematical result of the expression (d*j =
37.2). Indicate what the value stored in i would be.
double d=3.72; int i; int j=10; i
= d * j;// incorrect assignment
Explain what the output would be when executing the Question class
11. Create a traffic light where it starts at Red for 3 minutes, then Yellow for 1 minute, and continue to the
Green for 4m and then return to Red. The traffic light must always be active. Implement this algorithm in
any language or pseudocode.