java-programming-declarations-and-access-control Related Question Answers

26. / Missing statements ? / public class NewTreeSet extends java.util.TreeSet { public static void main(String [] args) { java.util.TreeSet t = new java.util.TreeSet(); t.clear(); } public void clear() { TreeMap m = new TreeMap(); m.clear(); } } which two statements, added independently at beginning of the program, allow the code to compile? No statement is required import java.util.; import.java.util.Tree; import java.util.TreeSet; import java.util.TreeMap;





27. Which three statements are true? The default constructor initialises method variables. The default constructor has the same access as its class. The default constructor invokes the no-arg constructor of the superclass. If a class lacks a no-arg constructor, the compiler always creates a default constructor. The compiler creates a default constructor only when there are no other constructors for the class.





28. package testpkg.p1; public class ParentUtil { public int x = 420; protected int doStuff() { return x; } } package testpkg.p2; import testpkg.p1.ParentUtil; public class ChildUtil extends ParentUtil { public static void main(String [] args) { new ChildUtil().callStuff(); } void callStuff() { System.out.print("this " + this.doStuff() ); / Line 18 / ParentUtil p = new ParentUtil(); System.out.print(" parent " + p.doStuff() ); / Line 20 / } } which statement is true?





29. You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access that accomplishes this objective?





30. public class Outer { public void someOuterMethod() { //Line 5 } public class Inner { } public static void main(String[] argv) { Outer ot = new Outer(); //Line 10 } } Which of the following code fragments inserted, will allow to compile?





31. interface Base { boolean m1 (); byte m2(short s); } which two code fragments will compile? interface Base2 implements Base {} abstract class Class2 extends Base { public boolean m1(){ return true; }} abstract class Class2 implements Base {} abstract class Class2 implements Base { public boolean m1(){ return (7 > 4); }} abstract class Class2 implements Base { protected boolean m1(){ return (5 > 7) }}





32. Which three form part of correct array declarations? public int a [ ] static int [ ] a public [ ] int a private int a [3] private int [3] a [ ] public final int [ ] a





33. public class Test { } What is the prototype of the default constructor?





Terms And Service:We do not guarantee the accuracy of available data ..We Provide Information On Public Data.. Please consult an expert before using this data for commercial or personal use | Powered By:Omega Web Solutions
© 2002-2017 Omega Education PVT LTD...Privacy | Terms And Conditions
Question ANSWER With Solution