Previous | Home | Next |
Answer: The package statement defines a name space in which classes are stored.If you omit the package, the classes are put into the default package.
Signature/java/. package pkg;
Use: * It specifies to which package the classes defined in a file belongs to. * Package is both naming and a visibility control mechanism.
Q.2 What is difference between importing "java.applet.Applet" and "java.applet.*;" ?
Answer: "java.applet.Applet" will import only the class Applet from the package java.applet Where as "java.applet.*" will import all the classes from java.applet package.
Answer:
- public: Anything declared as public can be accessed from anywhere.
- private: Anything declared in the private can’t be seen outside of its class.
- default: It is visible to subclasses as well as to other classes in the same package.
Answer: It is similar to class which may contain method’s signature only but not bodies.
Methods declared in interface are abstract methods. We can implement many interfaces on a class which support the multiple inheritance.
Answer: Yes. All the methods have to be implemented.
Answer: public.
Answer: Yes we can define a variable in an interface. They are implicitly final and static.
Answer: All the methods declared inside an Interface are abstract. Where as abstract class must have at least one abstract method and others may be concrete or abstract.
In Interface we need not use the keyword abstract for the methods.
(a). True
(b). False
Answer: (a). True
Q.10 Java compiler stores the .class files in the path specified in CLASSPATH environmental variable.
(a). True
(b). False
Answer: (b). False
Q.11 User-defined package can also be imported just like the standard packages.
(a). True
(b). False
Answer: (a). True
Answer: Throws
Answer: RuntimeException
Answer: Throwable
Answer: Exception
Q.16 The catch clause of the user-defined exception class should ______ its Base class catch clause.
Answer: Exception
Q.17 A _______ is used to separate the hierarchy of the class while declaring an Import statement.
Answer: Package
Answer: java.lang
Answer: *
Answer: YES. final and static
Answer: None
Answer: Yes
Q.23 Is it necessary to implement all the methods of an interface while implementing the interface?
Answer: No
Q.24 If you do not implement all the methods of an interface while implementing , what specifier should you use for the class ?
Answer: abstract
Answer: Using interfaces.
Answer: access class classname implements interface.
(a). True
(b). False
Answer: (a). True
Answer: Yes. final and static are the modifiers can be declared in an interface.
Q.29 What are the possible access modifiers when implementing interface methods?
Answer: public.
Answer: Yes
(a). True
(b). False
Answer: (b). False
Answer: Serializable, Cloneble & Remote.
Answer: Yes. Declare the class as abstract.
Previous | Home | Next |