1. What are standalone applications?
Standalone applications are programs written in Java to carry out certain tasks on a local computer. Executing a standalone Java program involves two steps :
l Compiling source code into byte code using javac compiler.
l Executing the bytecode program using Java interpreter.
2. What are applets?
Applets are small Java programs developed for internet applications.A applet located on a distant computer (server) can be downloaded via internet and executed on a local computer (client) using a Javaenabled browser. We can develop applets for doing everything from simple animated graphics to complex games and utilities. Since applets are embedded in an HTML document and run inside a web page, creating and running applets are complex than creating an application.
3. Difference between standalone applications and applets.
Standalone programs can read and write files and perform certain operations that applets cannot do. An applet can only run within a web browser.
4. What are local variables?
Variables declared and used inside methods are called local variables and these are accessible within the method only.
5. What are instance variables ?
Instance variables are created when the objects are instantiated and therefore they are associated with the object. They take different values for each object.
6. What are class variables?
Class variables are global to a class and belong to the entire set of objects that class creates.
7. What is Java Virtual Machine (JVM) ?
To achieve architecture neutrality, Java compiler produces an intermediate code known as bytecode for machine that does not exist. This machine is called Java Virtual Machine (JVM) and it exists only inside the computer memory. It is a simulated computer within the computer and does all major functions of a real computer.
The virtual machine code is not machine specific. The machine specific code (known as machine code) is generated by the Java interpreter by acting as an intermediary between the virtual machine and the real machine. Remember that interpreter is different for different machine.
8. What is wrapper class ?
Primitive data types may be converted into object types by using the wrapper classes contained in the java.lang package.
9. What are classes and objects?
A class defines the state and behavior of the basic program components known as objects. Classes create objects and objects use methods to communicate between them.
In other words, a class is a user-defined data type with a template that servers to define its properties.
10. What is a constructor?
A constructor enables an object to initialize itself when it is created.
Constructors have the same name as the class itself. And they do not specify a return type, not even void. This is because they return the instance of the class itself.
11. What is method overloading?
In Java, it is possible to create methods that have the same name, but different parameter lists and different definitions. This is called method overloading. Method overloading is used when objects are required to perform similar tasks but using different input parameters.
12. What is polymorphism?
When we call a method in an object, Java matches up the method name first and then the number and type of parameters to decide which one of the definitions to execute. This process is known as polymorphism.
13. What is inheritance?
The mechanism of deriving a new class from an old one is called inheritance.
The old class is known as the base class or super class or parent class and the new one is called the subclass or derived class or child class.
14. Explain the thumb rules of access specifiers.
l Use public if the field is to be visible everywhere.
l Use protected if the field is to be visible everywhere in current package and also subclass of other package.
l default visible everywhere in current package only.
l private protected visible subclass regardless of package.
l private not visible anywhere except own class.
15. Where the final keyword is used?
All methods and variables can be overridden by default in subclass. If we wish to prevent the subclass from overriding the members of the superclass, we can declare them as final using the keyword final as a modifier.
16. Explain the advantages of vectors over arrays.
Vectors posses a number of advantages over arrays :
l It is inconvenient to use vectors to store objects.
l A vector can be used to store a list of objects that may vary in size.
l We can add and delete objects from the list as and when required.
17. What is interface ?
An interface is basically a kind of class. Like classes, interfaces contain methods and variables but with a major difference. The difference is that interfaces define only abstract methods and final fields. This means that interfaces do not specify any code to implement these methods and data fields contains only constants.
Therefore, it is the responsibility of the class that implement an interface to define the code for implementation of these methods.
Note : Java does not support multiple inheritance. It means that Java cannot have more than one superclass. Java provides an alternative approach known as interface to support the concept of multiple inheritance.
18. What are packages in Java?
Packages are Java’s way of grouping a variety of classes and/or interfaces together. The grouping is usually done according to functionality. In fact, packages act as “container” of classes.
No comments:
Post a Comment