Previous | Home | Next |
Answer: Since Exception are of two type:
- Check Exception or Compile time Exception- Exception must by caught at the compile time.
- Uncheck Exception or Run time Exception- Exception caught at time of running program.
So, when exception is handling then its object loss it property and store into a temporary memory which is collect by garbage collector.
Answer: The two types of multi-tasking is
- Process based multi-tasking: in which more than two process/multiple process run concurrently.
- Thread based multi-tasking: in which multiple threads executes concurrently.
Answer: Thread is created in two ways:
- Implement Runnable interface.
- Creating subclasses of thread.
Answewr: The synchronized keyword can be used for locking in program or utilize for lock/ free the resource for any thread/program.
Answer: The filter driver determines the total bandwidth of the disk. I/O filters generally used for reading from one stream and writing another stream.
Q.237 Can applet in different page communicate with each other?
Answer: Since, Java almost Object oriented language( OOPs) but it not 100% OOPs language because:
- Java supportPrimitive data types like float, double, int, short, long, byte, char, boolean.
- Java call static method with out making instance of it.
- Java doesn't support Multiple inheritance directly.
Answer:
- Interface: An interface is an entity, not a class. It contain only signature of a method( no body).
- Abstract class: Abstract class let you define some behavior of method( no body) which used in subclass.
So, Abstract class is good option in between uses of an Abstract class and an interface because Abstract class able to customized behavior of method as need in a program.
Answer: Thread to thread communication means one thread able to sleep, wait, resume even dead to another thread on respected method call.
Q.241 Describe difference between method overriding and overloading?
Answer: Two method not have same name, same argument while return type is same.
Answer: When two methods and operator (within different class) have the same name and same arguments , but different signature, it is known as overloading. Method can be overload by its same argument type.
Answer: HYPERTEXT TRANSFER PROTOCOL( HTTP) is called a stateless protocol because each command is executed independently, withoutremember the previous knowledge of the commands. It is used for transferring WEB PAGES from a WEB SERVER to a BROWSER.
Answer: Construction chaining( or constructor hierarchy), a subclass constructor method's first call to its superclass's constructor method similar to the inheritance.
Used the following program for Constructor hierarchy.
/* * save as a AnimalProperty.java * Program display the Construction chaining or constructor hierarchy. */ package r4r.co.in; public class AnimalProperty { public static void main(String[] args) { Cat c = new Cat(); //Create object } } class Cat extends Dog { public Cat() { System.out.println("Cat hates Dogs: "); } } class Dog extends Animal { public Dog() { System.out.println("Dog is Barking on Cat, even hat cats "); } } class Animal { public Animal() { System.out.println("Animal Property: Dog is bigger than Cat "); } }
Result:
Q.246 What is passed by ref and by value?
Q.247 How to ensure size of a primitive data type?
Q.248 Elaborate the Garbage Collection process in Java ?
Q.249 What is a difference between An interface and an abstract class?
Q.250 In DB access where to write the query. In JSP or servlet?
Answer: A constructer is the member function of the class, used for create the object of that class. Constructor define as a class name with no return value, and invoke using a new operator.
A method is also member function of the class, used for create the object of that class. Method have own name and return value( include null and void), and invoked using a dot operator.
Take look a program:
/* * Sava as a Final.java * Program for declare Constructer and 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) { //It declare a Constructer Final f = new Final(); //It declare a Method f.Test();// } }
Answer: In Java, serialization is the process for converting a set of object instance, contain references into linear stream of bytes which can be store into File( memory), send through socket, or simply manipulate as a data stream. Also, serialization is the mechanism to pass a object between JVMs to a server or return values from a method invocation, either as argument in a method invocation from a client used by RIM.
Take a look of program:
/* * Save as a Time.java * Program that display Current Time */ package r4r.co.in; import java.io.Serializable; import java.util.Calendar; import java.util.Date; public class Time implements Serializable { private Date time; public Time() { time = Calendar.getInstance().getTime(); System.out.print(time); } public Date getTime() { return time; } public static void main(String[] args) { //Create object Time t = new Time(); } }
Result:
Answer:
Error: An error is an irrecoverable condition occurring at runtime. The Java Virtual machine( JVM) can't able to handle Error in the program.
- Example of Error condition: Stack overflow, Memory out of bound.
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.
Answer:
Procedural objective language: Procedural language is totally dependent/ concentrate on procedures, method and functions. It normally work on the flowchart scenarios like top to down approach. The main disadvantage of that is it totally focuses on methods and not the data which is utilized by methods.
- Example of such language: FORTRAN , COBOL, PASCAL and C.
Object oriented language: OOPs is a programming paradigm that used Object ( instance of class) to design computer program and application. OOPs language must have features such as data abstraction, encapsulation, modularity, polymorphism, and inheritance.
- Example of such language- C#, C++, JAVA and VB.Net.
Answer:
Class is the prototype/ blueprint from which object is create. Class is used to declare fields, constructors , and methods.
Object is an instance of a class exhibits two characteristics such as state and behavior. Each class has Object as a superclass.
Previous | Home | Next |