programming languages Online Quiz - 178
Description: programming languages Online Quiz - 178 | |
Number of Questions: 20 | |
Created by: Aliensbrain Bot | |
Tags: programming languages |
Given: class CardBoard { Short story = 5; CardBoard go(CardBoard cb) { cb = null; return cb; } public static void main(String[] args) { CardBoard c1 = new CardBoard(); CardBoard c2 = new CardBoard(); CardBoard c3 = c1.go(c2); c1 = null; // do Stuff } } When // doStuff is reached, how many objects are eligible for GC?
Given: 1. class Convert { 2. public static void main(String[] args) { 3. Long xL = new Long(456L); 4. long x1 = Long.valueOf("123"); 5. Long x2 = Long.valueOf("123"); 6. long x3 = xL.longValue(); 7. Long x4 = xL.longValue(); 8. Long x5 = Long.parseLong("456"); 9. long x6 = Long.parseLong("123"); 10. } 11. } Which will compile using Java 5, but will NOT compile using Java 1.4? (Choose all that apply.)
Given: 1. class Bigger { 2. public static void main(String[] args) { 3. // insert code here 4. } 5. } 6. class Better { 7. enum Faster {Higher, Longer}; 8. } Which, inserted independently at line 3, will compile? (Choose all that apply.)
Given: 1. class Example { 2. public static void main(String[] args) { 3. Short s = 15; 4. Boolean b; 5. // insert code here 6. } 7. } Which, inserted independently at line 5, will compile? (Choose all that apply.)
Given two files: 1. class One { 2. public static void main(String[] args) { 3. int assert = 0; 4. } 5. } 1. class Two { 2. public static void main(String[] args) { 3. assert(false); 4. } 5. } And the four command-line invocations: javac -source 1.3 One.java javac -source 1.4 One.java javac -source 1.3 Two.java javac -source 1.4 Two.java What is the result? (Choose all that apply.)
Given: class Mixer { Mixer() { } Mixer(Mixer m) { ml = m;} Mixer m1; public static void main(String[] args) { Mixer m2 = new Mixer(); Mixer m3 = new Mixer(m2); m3.go(); Mixer m4 = m3.m1; m4.go(); Mixer m5 = m2.m1; m5.go(); } void go() { System.out.print("hi "); } } What is the result?
Given: 1. class Zippy { 2. String[] x; 3. int[] a [] = {{1,2}, {l}}; 4. Object c = new long [4] ; 5. Object[] d = x; 6. } What is the result?
Given: class Knowing { static final long tooth = 343L; static long doIt(long tooth) { System.out.print(++tooth + " "); return ++tooth; } public static void main(String[] args) { System.out.print(tooth + " "); final long tooth = 340L; new Knowing().doIt(tooth); System.out.println(tooth); } } What is the result?
Given: 1. class Eco { 2. public static void main(String[] args) { 3. Eco e1 = new Eco(); 4. Eco e2 = new Eco(); 5. Eco e3 = new Eco(); 6. e3.e = e2; 7. e1.e = e3; 8. e2 = null; 9. e3 = null; 10. e2.e = el; 11. e1 = null; 12. } 13. Eco e; 14. } At what point is only a single object eligible for GC?
Given: class Clidders { public final void flipper() { System.out.print(" Flip a Clidder"); } } public class Clidlets extends Clidders { public void flipper() { System.out.print(" Flip a Clidlet"); super.flipper(); } public static void main(String [] args) { new Clidlets().flipper(); } } What is the result?
Given:class Clidder { private final void flipper() { System.out.print(" Flip a Clidder"); }}public class Clidlet extends Clidder { public final void flipper() { System.out.print(" Flip a Clidlet"); } public static void main(String [] args) { new Clidlet().flipper(); }}What is the result?
Given: public class Foo { Foo() {System.out.print("foo");} class Bar{ Bar() {System.out.print("bar");} public void go() {System.out.print("hi");} } public static void main(String[] args) { Foo f = new Foo (); f.makeBar(); } void makeBar() { (new Bar() {}).go(); } } What is the result?