Log In Register

Units


Interfaces - Questions and Answers

 

Practice these Interfaces under Java Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Interfaces for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Interfaces of Java Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge Java Programming specifically Interfaces.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Interfaces under Java Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Interfaces topic of Java Programming:

 

1. interface Test{ int p = 10; //line 1 public int q = 20; //line 2 public static int r = 30; //line 3 public static final int s = 40; //line 4 } Which of the above line will give compilation error?

Answer: Option D

Explanation:

2. Runnable is a _____ .

Answer: Option C

Explanation:

3. Which of the following class definitions defines a legal abstract class?

Answer: Option C

Explanation:

4. Suppose A is an abstract class, B is a concrete subclass of A, and both A and B have a default constructor. Which of the following is correct? 1. A a = new A(); 2. A a = new B(); 3. B b = new A(); 4. B b = new B();

Answer: Option B

Explanation:

5.  Which of these method waits for the thread to treminate?

Answer: Option C

Explanation:

6. What will be the output when the following program is compiled and executed? abstract class TestAbstract{ String my_name; String myName(){ my_name = "TestMirror"; return my_name; } abstract void display(); } public class Test extends TestAbstract{ void display(){ String n = myName(); System.out.print("My name is "+ n); } public static void main(String a rgs[]){ Test t = new Test(); t.display(); } }

Answer: Option A

Explanation:
The options B, C and D are incorrect options as in Java we can declare an abstract class comprising of abstract and non-abstract methods that will not lead to any compilation error. Therefore, A is the correct answer implying that the 't' instance of Test class invokes the display method, which is implemented in the Test class. The display method invokes myName() method declared int the TestAbstract class and prints the name.

7. Which of these method is used to begin the execution of a thread?

Answer: Option B

Explanation:

8. Which of these interface is implemented by Thread class?

Answer: Option A

Explanation:

9. What will be the output for the below code ? public interface TestInf{ int i =10; } public class Test{ public static void main(String ... args){ TestInf.i=12; System.out.println(TestIn f.i); }

Answer: Option A

Explanation:
All the variables declared in interface is implicitly static and final , therefore can't change the value.

10. Which of the following statements regarding abstract classes are true?

Answer: Option D

Explanation:

11. Which of the following is a correct interface?

Answer: Option D

Explanation:

12. Which of these can be used to fully abstract a class from its implementation?

Answer: Option C

Explanation:

13.  Which of the following package stores all the standard java classes?

Answer: Option B

Explanation:

14.  Which of these method is used to implement Runnable interface?

Answer: Option B

Explanation:
To implement Runnable interface, a class needs only to implement a single method called run().

15. Given the following piece of code: public class School{ public abstract double numberO fStudent(); } which of the following statements is true?

Answer: Option D

Explanation: