Which three form part of correct array declarations?
You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?
What will be the output of the program?
public class ArrayTest
{
public static void main(String[ ] args)
{
float f], f];
f1 = new float[10];
f2 = f
System.out.println("f2[= " + f2[0]);
}
}
What will be the output of the program?
public class Test
{
public int aMethod()
{
static int i = i++;
return i;
}
public static void main(String args[])
{
Test test = new Test();
test.aMethod();
int j = test.aMethod();
System.out.println(j);
}
}
Which two of the following are legal declarations for nonnested classes and interfaces?
public class Test { }
What is the prototype of the default constructor?What will be the output of the program?
class Super
{
public Integer getLength()
{
return new Integer(4);
}
}
public class Sub extends Super
{
public Long getLength()
{
return new Long(5);
}
public static void main(String[] args)
{
Super sooper = new Super();
Sub sub = new Sub();
System.out.println(
sooper.getLength().toString() + "," + sub.getLength().toString() );
}
}
Which of the following class level (nonlocal) variable declarations will not compile?
interface DoMath
{
double getArea(int rad);
}
interface MathPlus
{
double getVol(int b, int h);
}
/* Missing Statements ? */
which two code fragments inserted at end of the program, will allow to compile?
Which two statements are true for any concrete class implementing the java.lang.Runnable interface?
/* 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?
Which three statements are true?
package testpkg.ppublic class ParentUtil
{
public int x = protected int doStuff() { return x; }
}
package testpkg.pimport 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*/
ParentUtil p = new ParentUtil();
System.out.print(" parent " + p.doStuff() ); /* Line*/
}
}
which statement is true?