Chapter 3
Q1) What does this code do?
// setContentView(R.layout.activity_main);
A) Nothing, because it is commented out with //.
Q2) Which of these lines causes an error?
String a = "Hello"; String b = " Vinton Cerf"; int c = 55; a = a + b c = c + c + 10; a = a + c; c = c + a;
A) The fourth line, a = a + b
, has no semicolon, so it will cause an error. The last line, c = c + a;
, will also cause an error because you cannot assign a string to an int
value.
Q3) We talked a lot about operators and how different operators can be used together to build complicated expressions. Expressions, at a glance, can sometimes make code look complicated. However, when looked at closely, they are not as tough as they seem. Usually, it is just a case of splitting the ...
Get Android Game Programming: A Developer’s Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.