Win a copy of Head First Android this week in the Android forum!

Vlad Alin

Ranch Hand
+ Follow
since Nov 01, 2021
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
7
Received in last 30 days
7
Total given
1
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vlad Alin

package mode;
public class Transportation {
  public static String travel(int distance) {
     return distance<1000 ? "train" : 10;
  }
  public static void main(String[] answer) {
     System.out.print(travel(500));
  }
}

25. C. Ternary operations require both right-hand expressions to be of compatible data types.
In this example, the first right-hand expression of the outer ternary operation is of type
String, while the second right-hand expression is of type int.

"outer" should be removed because there is no inner ternary
You know what i mean. It should say because of assignment. By itself it is allowed to be different types.
I don't know if this is really a mistake because the ternary was inside a method with String return type.
It should say because of String return type?
Sybex:Java OCA/OCP 8 Practice Tests Chapter 3 question 25 mock answer incorrect fact

25. Ternary operations require both right-hand expressions to be of compatible data types.



It should say only when combined with the assignment operator.
There is no requirement that the second and third expressions in ternary operations have the same data type.

by alinvlad05
Sybex Java OCA/OCP PRACTICE TESTS 8 typo ch3 mock answer 2

total=5+ (5>6 ? ++tip : --tip)

The value of total is 6, since the pre-increment operator was used on tip.

It should be pre-decrement instead of pre-increment

by alinvlad05
Sybex Java OCA/OCP PRACTICE TESTS 8 typo ch2 mock answer 44

p[beakLength]=b;

In Java, braces are for arrays rather than instance variables.


It should be Brackets [] instead of Braces {}

by alinvlad05
Sybex Java OCA/OCP 8 typo ch2 mock answer 26

Since defaultVaIue is an instance variable
It should be "class variable" because it is STATIC.

by alinvlad05
Sybex:Java OCA/OCP Practice Tests Chapter 1 question 12 mock answer

The birds variable is not static and requires a class instance variable to access.

It should be "class instance" instead of  "class instance variable".

by alinvlad05
21.
Finally, the variable tomorrow is static.

It should be variable yesterday is static.

by alinvlad05
Sybe:Java OCA/OCP Practice Tests Chapter 1 question 12 mock answer

The birds variable is not static and requires a class instance variable to access.

It should be "class instance" instead of  "class instance variable".

by alinvlad05
int x = 5;
System.out.println(x < 4 ? 10 : 8);