• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 51 : - Can you write a Java class that could be used both as an applet as well as an application?

Answer - 51 : - A. Yes. Add a main() method to the applet.

Question - 52 : - In System.out.println(),what is System,out and println,pls explain?

Answer - 52 : - System is a predefined final class,out is a PrintStream object acting as a field member and println is a built-in overloaded method in the out object.

Question - 53 : - Can you declare a class as private?

Answer - 53 : - Yes, we can declare a private class as an inner class. For example, class MyPrivate { private static class MyKey { String key = "12345"; } public static void main(String[] args) { System.out.println(new MyKey().key);//prints 12345 } }

Question - 54 : - Name primitive Java types ?

Answer - 54 : - The primitive types are byte, char, short, int, long, float, double, and Boolean.

Question - 55 : - Which package has light weight components?

Answer - 55 : - javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.

Question - 56 : - What is the immediate superclass of the Applet class?

Answer - 56 : - Panel

Question - 57 : - What is the difference between interface and abstract class?

Answer - 57 : - interface contains methods that must be abstract; abstract class may contain concrete methods. interface contains variables that must be static and final; abstract class may contain non-final and final variables. members in an interface are public by default, abstract class may contain non-public members. interface is used to "implements"; whereas abstract class is used to "extends". interface can be used to achieve multiple inheritance; abstract class can be used as a single inheritance. interface can "extends" another interface, abstract class can "extends" another class and "implements" multiple interfaces. interface is absolutely abstract; abstract class can be invoked if a main() exists. interface is more flexible than abstract class because one class can only "extends" one super class, but "implements" multiple interfaces. If given a choice, use interface instead of abstract class.

Question - 58 : - What are wrapper classes?

Answer - 58 : - Wrapper classes are classes that allow primitive types to be accessed as objects.

Question - 59 : - What are use cases?

Answer - 59 : - A use case describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance. It is part of the analysis of a program. The collection of use cases should, ideally, anticipate all the standard circumstances and many of the extraordinary circumstances possible so that the program will be robust.

Question - 60 : - How are this() and super() used with constructors?

Answer - 60 : - this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners