Q. Which of the given statement is not true about a Java Package?
Q. Given two files, what will be the Output?
package pck1;
public class A
{
int x = 10;
public int y = 20;
}
package pck2;
import pck1.*;
class Test
{
public static void main(String []args)
{
A a = new A(); // line 7
System.out.println(a.x); // line 8
System.out.println(a.y); // line 9
}
}
Q. import
keyword is used to?
Q. You can import only static members of a class present in some other package using __________?
Q. Which of the statement is false about an abstract class?
Q. Fill in the blank to compile the code successfully?
abstract class A
{
int a = 100;
public abstract void showA(); }
public class B extends A
{
_ _ _ _ _ _ _ _ _ // Fill the blank
public static void main(String []args)
{
A objA = new B();
objA.showA();
}
}
Q. Which is a valid declaration within an Interface?
Q. Which of the following statement is true about an Interface?
Q. Which of following is a valid class using the given code?
public interface A { public void showA(); }
Q. Given the following declarations, which assignment is legal?
// Class declarations :
interface A {}
class B {}
class C extends B implements A {}
class D implements A {}
// Declaration statements :
B b = new B();
C c = new C();
D d = new D();