Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

Commit f069d8f

Browse files
author
Ram swaroop
committed
added content
1 parent ede1591 commit f069d8f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

_posts/2015-05-14-variables-and-literals.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,33 @@ long as the class stays loaded in the Java Virtual Machine (JVM).
373373
2. __Instance or non-static__ variables are the next most long-lived. They are created when a new instance is created,
374374
and they live until the instance is removed.
375375
3. __Local__ variables are next. They live as long as their method remains on the stack. As we'll soon see, however,
376-
local variables can be alive and still be "out of scope."
376+
local variables can be alive and still be "out of scope".
377377
4. __Block__ variables live only as long as the code block is executing.
378378

379+
380+
381+
382+
379383
{% include responsive_ad.html %}
380384

381385
### Q&A
382386

383-
__Q1.__
387+
__Q1.__
388+
{% highlight java linenos %}
389+
public class Fishing {
390+
byte b1 = 4;
391+
int i1 = 123456;
392+
long L1 = (long)i1; // line A
393+
short s2 = (short)i1; // line B
394+
byte b2 = (byte)i1; // line C
395+
int i2 = (int)123.456; // line D
396+
byte b3 = b1 + 7; // line E
397+
}
398+
{% endhighlight %}
399+
400+
Which lines WILL NOT compile? (Choose all that apply.)
401+
A. Line A
402+
B. Line B
403+
C. Line C
404+
D. Line D
405+
E. Line E

0 commit comments

Comments
 (0)