Previous | Home | Next |
Q.183 What is the mapping mechanism used by Java to identify IDL language ?
Answer: The differences between an applet and an application are as follows:
Application | Applet | Applications have no inherent security restrictions. | Applets executes under security limitations( sandbox security model) that disallow certain operation and divide into two category-trusted and untrusted applet. |
Applications are executed at command line by java.exe or jview.exe. | It is only run inside a java compatible container, such as appletviewer or browser. |
Application must have main() method for initialization. | Applet have different mechanism such as init() method- use for initialization or load a applet. start() method- use for start a applet. stop() method- use for stop a applet. destroy() method- use for clean up or unload the applet. |
Application doesn't embedded inside a HTML page. | Applet can be embedded in HTML page and access any where. |
Q.185 What is fertilizable Interface ?
Answer: Difference between them:
Servlet | Common Gateway Interface( CGI) |
Servlet techniques is born with JSP in June, 1997 | It is first practical techniques for creating dynamic content. |
It is Java-based Web component( like HTML or XML), managed by Servlet container( part of Web server or application server), help to provided dynamic content. | CGI program is written in language—most commonly C, C++, Perl, and Python. |
It is totally platform independent. | It is platform dependent. |
Servlet can able to access the large set of APIs available for the Java platform. so it consume less resource. | CGI programs typically use a large amount of system resources like large amount of memory and CPU usage. |
Answer:
Interface: An interface is an entity, not a class. It contain only signature of a method( no body). In java interface play two important role such as
- It helps to apply multiple inheritance concept in the program.
- It is used to implement the late-binding concept in program. Late-binding is the process of passing the value/ functionality to a function dynamically.
Q.188 Why Java is not fully objective oriented ?
Q.189 Why does not support multiple Inheritance ?
Answer: Object class is the root class of all the java classes.
Q.191 What is polymorphism ?
Q.192 Suppose If we have variable ‘ I ‘ in run method, If I can create one or More thread each thread will occupy a separate copy or same variable will be shared ?
Q.193 What is Constructor and Virtual function? Can we call Virtual?
Q.194 What is function in a constructor ?
Answer: OOPs is a programming paradigm that used Object ( instance of class) to design computer program and application. Concepts of OOPs
- Object: An object is an instance of a class exhibits two characteristics such as state and behavior. Each class has Object as a superclass. When program is execute the objects interact each other by sending message and values.
- Classes: Class is the prototype/ blueprint from which object is create. Class is used to declare fields, constructors , and methods.
- Inheritance: Inheritance means to take something that is already made. It is one of the most important features of Object Oriented Programming. It is the concept that is used for reusability purpose. Inheritance is the mechanism through which we can derive classes from other classes. The derived class is called as childclass or the subclass or we can say the extended class and the class from which we are deriving the subclass is called the base class or the parent class. To derive a class in java the keyword extends is used.
- Polymorphism: Generally, polymorphism is a concept in which a subclass( or
child class) can be easily inherited the member (like method, parameter and
signature) of superclass (or parent class) but not vice-versa.
Polymorphism may be two kind:
- Method overloading
- Method overriding
- Data Abstraction and Encapsulation: Abstraction means
represent only essential features and hide the background details or
explanations.Classes use the concept of abstraction and are defined as a list
of abstract attributes.
Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.
Answer: Difference between them:
C++ Language | Java Language |
Write once compile anywhere but not everywhere. | Write once run anywhere / everywhere. |
Allows both object-oriented programming and procedural programming. | Allow and encourages an object oriented programming paradigm. |
Memory management is explicit though third party frameworks exist to provide garbage collection. Supports destructors. | Memory management is automatic/manually by garbage collection, Doesn't support the concept of Destructor and usage of finalize() is not recommended. |
Supports class, struct, and union and can allocate them on heap or stack. | Supports only class and allocates them on the heap. |
Support the Pointers, References, and pass by value. | Primitive and reference data types always passed by value. |
Support Operator overloading for most operators. | In java, meaning of operators is generally immutable, however string support such operator + and += for overload. |
Support multiple inheritance, including virtual inheritance. | Single inheritance only from classes, multiple from interfaces. |
Supports the goto statement. | Supports labels with loops and statement blocks. |
const keyword for defining immutable variables and member functions that do not change the object. | Don't support both const member functions and const type pointers, but final provides a limited version of const. |
No standard inline documentation mechanism. Dependent on 3rd party software (e.g. Doxygen) exists. | Java have standard documentation called Javadoc. |
Source code can be written to be platform independent but compilation is dependent because it is typically depend into native machine code. | It is compiled into byte code for the JVM which convert it into machine level language, but it is time consuming process. i.e. java is platform independent language. |
Q.197 What is the exact difference in between Unicast and Multicast object ? Where we will use ?
Answer: Unicast object means there is one receiver. Use multicast to allow one-to-many connections. The example for multicast is the java eventhandling model.
Q.198 How do you sing an Applet ?
Q.199 In a Container there are 5 components. I want to display the all the components names, how will you do that one ?
Q.200 Why there are some null interface in java ? What does it mean ?
Answer: Interface without any method is called Marker or Null Interface like
- Serializable interface.
- Externalizable interface.
- Cloneable interface.
Q.202 Tell me the latest versions in JAVA related areas ?
Q.203 What is meant by class loader ? How many types are there? When will we use them ?
Q.204 What is meant by flickering ?
Answer: A short information can saved by the client browser and send to the server when session is terminated or close the browser. Cookies contain cookies value (uniquely identify a client ), name ,session ID and optional attributes like maximum age, version number, path and comment . so it commonly used in session management.
Q.206 Which problem you had faced in your earlier project?
Q.207 How OOPS concept is achieved in Java?
Q.208 What is features for using Java?
Q.209 How does Java 2.0 differ from Java 1.0?
Answer: Main method declaration Syntax:
class R4R { //Main method is the method in which execution to any java program begins. public static void main(String[] args) { //Display/ print message on the screen System.out.println("Hello R4R Tech Soft"); } }
- public: declares that the main method is publicly accessible to other classes and the JVM to begin execution of the program.
- static: declares that the main method can be invoked without creating an instance of the class. So you cannot begin execution of a class without its object if the main method was not static.
- void: declares that the main method does not return any value and once the main method execution is over, the program terminates.
- main: defines the name of the method.
- String[] args): defines a parameter to the main method which will contain any command line options passed by the user when invoking the program The Java compiler would accept both forms of String[] args)or String args[]).
Q.211 What are command line arguments?
Q.212 Explain about the three-tier model?
Answer:Difference between them:
String | StringBuffer |
String is a class that represents an immutable string that means sequence of characters that can never change in the program. | StringBuffer (a StringBuilder, add in Java 1.5 ) is a mutable string object that can be modified or change at runtime. |
Sting size is Fixed. | StringBuffer size is varied (growable). |
Any modification to the String will have to create a new String object. | Since object value is change on runtime, so no need to create a new String object. |
String is generally lighter and faster to use where the String isn't going to change. | It is more heaver, but when building a long String of text and by making changes to one object over time than use a StringBuffer/ StringBuilder (synchronization is very important here) |
Answer: Repeat---- No, string is not a Wrapper class.
Q.215 What are the restriction for static method Purpose of the file class?
Answer: Public (in abstract form) is default modifier in Interface.
Answer:
- Interface: An interface is an entity, not a class. It contain only signature of a method( no body).
- bstract class: Abstract class let you define some behavior of method( no body) which used in subclass.
Answer: No, it is not recommended to be declare abstract class as Final because an abstract class must be implement into its subclass and Final don't allow that.
Use the following program syntax.
/* * Sava as a Final.java * Program for declare a variable as final variable inside method. * Any Final method can't be override in its subclass. */ package r4r.co.in; public class Final { public Final() { //Declared i as a final final int i = 10; System.out.println("Initially, value of i:" + i); } void Test() { /* * Compile time error "Variable i not found" * Incompatible type, required int i. */ int a = 1 + i; } public static void main(String[] args) { Final f = new Final(); //Object create "Final" f.Test(); } }
Answer: Yes, final variable can be declare inside the method. Take a look of program.
/* * Save as a FinalVar.java * Program display that Final variable * Any Final method can't be override in its subclass. */ package r4r.co.in; //SuperClass class FinalVar { public FinalVar() { //Declared i as a final variable final int i; System.out.print("Initial value of i: "); } //Subclass can't inheret all final method form its Superclass class Test extends FinalVar { int a = 10, c = 12; //Compilation error, variable i not found i = a + c; System.out.print("Sum of two value is: " + i); } public static void main(String[] args) { //Create object FinalVar fi = new FinalVar(); } }
Answer: A package is a namespace that include classes and interfaces. The Java platform provides an enormous class library( called package), suitable for own applications, library is known as a "Application Programming Interface (API)" . The Packages extend the concept of development classes with the addition of new attributes:
- Visibility: It is a property belongs to package element (such as classes and interface), but element may be visible outside their package. Element those visible outside the package ( or other package), it must be contained in at least one package interface.
- Nesting: It allow a package to embedded into another package by keyword import.
- Interfaces: Packages use interfaces and visibility to make their services known to other packages.
- use accesses: Use access is the right of one package to use the visible elements in the interface of a second package (but not the other way round). *Note Class doesn't declare as Final.
Answer: A Thread is considered to be dead when it completes its run() method. We can't call a start() method on a given Thread object for the second time. Hence a dead thread can't be restarted.
Q.222 Difference between Applet & Application?
Answer: The life cycle of applet is define in four basic method which is
- init() method: use for initialized and load the applet into applet viewer or browser.
- start() method: use for start the applet in applet viewer or browser.
- stop() method: use for stop the running applet.
- destroy() method: use for final clean up or unload the the applet.
*Note that when webpage is refresh or reload the current instance of applet is stop and destroy( by calling stop() and destroy() method itself), after that a new instance of same applet is generated automatically.
Answer: Yes, applet have constructors. But applets don't usually have constructors because an applet isn't guaranteed to have a full environment until its init() method is called. Applet constructor is just like any other constructor, they cannot be overridden.
Answer: A Canvas object provides access to a Graphics object via its paint() method.
Answer:
- Superclass: A object class act as a superclass, sits at the top of the class hierarchy tree in the java.lang package. Every class is a descendant, direct or indirect, of the Object class.
- SubClass: Every class can have a Super class from which it inherits properties and methods in it called subclass. Any class can be extended, or sub-classed so the resulting subclass can inherit its parent's behavior and property.
Answer: When an applet is first created, an applet stub is attached to it using the applet's setStub method because stub serves as the interface between the applet and the browser or applet viewer in which the application is running. AppletStub interface contain some of method like:
- void appletResize(int width, int height): used to when the applet wants to be resized.
- getAppletContext(): use to handler the applet's context.
- getParameter(String name): use to get the named/string parameter from the HTML/Field tag.
- isActive(): use to determines the state of applet.
- getCodeBase(): use to gets the URL of applet.
- getDocumentBase(): use to gets the URL of the document in which the applet is embedded.
Answer: The StreamTokenizer class takes an input stream and parses it into "tokens", allowing the tokens to be read one at a time.
Use the following:
Reader read = new BufferedReader(new InputStreamReader(is)); StreamTokenizer st = new StreamTokenizer(read);
Q.228 What is the difference between two types of threads?
Answer:
Exception-: An exception is an abnormal condition that arises in a code sequence due to bad code by user at the compile time and run time. Usually, it is coverable by using special type of syntax. Exception also two type such as
- Compile time or Check Exception: Exception generated at the time of Compilation of the program, such as ClassNotFound, cloneNotSupport etc.
- Run time or Uncheck Exception: Exception generated at the time of running the program, such as Arithmetic, SQL, nullPointer, indexOutOfBound etc.
Q.230 What is use of throws keyword in Exception thrown?
Q.231 What is finally in exception handling Vector class?
Previous | Home | Next |