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. Which of these method is used to begin the execution of a thread?

Answer: Option B

Explanation:

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

Answer: Option B

Explanation:

3. Which of the following declares an abstract method in an abstract Java class?

Answer: Option B

Explanation:

4. Which of the following is a correct interface?

Answer: Option D

Explanation:

5. Which of the following is correct way of implementing an interface salary by class manager?

Answer: Option B

Explanation:

6. Determine output of the following code. interface A { } class C { } class D extends C { } class B extends D implements A { } public class Test extends Thread{ public static void main(String [] args){ B b = new B(); if (b instanceof A) System.out.pri ntln("b is an instance of A"); if (b instanceof C) System.out.pri ntln("b is an instance of C"); } }

Answer: Option D

Explanation:

7. In Java, declaring a class abstract is useful

Answer: Option B

Explanation:

8. 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.

9.  Which of the following is incorrect statement about packages?

Answer: Option D

Explanation:
All methods and variables are implicitly public if interface is declared public.

10. Which of these keywords is used to define interfaces in Java?

Answer: Option A

Explanation:

11. 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:

12. Which of these statement is incorrect?

Answer: Option D

Explanation:
run() method is used to define the code that constitutes the new thread, it contains the code to be executed. start() method is used to begin execution of the thread that is execution of run(). run() itself is never used for starting execution of the thread.

13. Runnable is a _____ .

Answer: Option C

Explanation:

14. What will be the output? 1. public interface InfA{ 2. protected String getName(); 3. } public class Test implements InfA{ public String getName(){ return "test-name"; } public static void main (String [] args){ Test t = new Test(); System.out.println(t.getName()); } }

Answer: Option B

Explanation:
Illegal modifier for the interface method InfA.getName(); only public and abstracts are permitted.

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

Answer: Option C

Explanation: