File tree Expand file tree Collapse file tree 1 file changed +34
-3
lines changed
Expand file tree Collapse file tree 1 file changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -482,7 +482,8 @@ explicitly initialize them with a value.
482482
483483### Q&A
484484
485- __ Q1.__
485+ __ Q1.__ Given the below program:
486+
486487{% highlight java linenos %}
487488public class Fishing {
488489 byte b1 = 4;
@@ -502,7 +503,7 @@ C. Line C
502503D. Line D
503504E. Line E
504505
505- __ Q2.__
506+ __ Q2.__ Given the below program:
506507
507508{% highlight java linenos %}
508509class Mixer {
@@ -537,4 +538,34 @@ B. hi hi
537538C. hi hi hi
538539D. Compilation fails
539540E. hi, followed by an exception
540- F. hi hi, followed by an exception
541+ F. hi hi, followed by an exception
542+
543+ __ Q3.__ Given the below program:
544+
545+ {% highlight java linenos %}
546+ class Fizz {
547+ int x = 5;
548+
549+ public static void main(String[] args) {
550+ final Fizz f1 = new Fizz();
551+ Fizz f2 = new Fizz();
552+ Fizz f3 = FizzSwitch(f1, f2);
553+ System.out.println((f1 == f3) + " " + (f1.x == f3.x));
554+ }
555+
556+ static Fizz FizzSwitch(Fizz x, Fizz y) {
557+ final Fizz z = x;
558+ z.x = 6;
559+ return z;
560+ }
561+ }
562+ {% endhighlight %}
563+
564+ What is the result?
565+ A. true true
566+ B. false true
567+ C. true false
568+ D. false false
569+ E. Compilation fails
570+ F. An exception is thrown at runtime
571+
You can’t perform that action at this time.
0 commit comments