Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
30Activity
0 of .
Results for:
No results containing your search query
P. 1
Java - Descriptive Questions and Answers

Java - Descriptive Questions and Answers

Ratings: (0)|Views: 1,519|Likes:
Published by api-3728136

More info:

Published by: api-3728136 on Nov 29, 2009
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

Java and Advanced Java: Descriptive Questions and answers for Students.
CORE JAVA
Question: Can a private method of a superclass be declared within a subclass?
Answ er: Sure. A private field or method or inner class belongs to its declared class and hides
from its subclasses. There is no way for private stuff to have a runtime overloading or
overriding (polymorphism) features.
Question: Why Java does not support multiple inheritence?
Answ er: Java DOES support multiple inheritance via interface implementation.
Question: What is the difference between final, finally and finalize?
Answ er: o final - declare constant
o finally - handles exception
o finalize - helps in garbage collection
Question: Where and how can you use a private constructor?
Answ er: Private constructor can be used if you do not want any other class to instanstiate

the object, the instantiation is done from a static public method, this method is used when dealing with the factory method pattern when the designer wants only one controller (fatory method) to create the object.

Question: In System.out.println(), what is System, out and println, pls explain?
Answ er:Sy st e m is a predefined final class, o u t is a PrintStream object and p r i n t l n is a built-
in overloaded method in theo u t object.
Question: What is meant by "Abstract Interface"?
Answ er: First, an interface is abstract. That means you cannot have any implementation in
an interface. All the methods declared in an interface are abstract methods or signatures of
the methods.
Question: Can you make an instance of an abstract class? For example - java.util.Calender
is an abstract class with a method getInstance() which returns an instance of the Calender
class.
Answ er: No! You cannot make an instance of an abstract class. An abstract class has to be

sub-classed. If you have an abstract class and you want to use a method which has been implemented, you may need to subclass that abstract class, instantiate your subclass and then call that method.

Question: What is the output of x< y? a:b = p* q when x= 1,y= 2,p= 3,q= 4?
Answ er: When this kind of question has been asked, find the problems you think is
necessary to ask before you give an answer. Ask if variables a and b have been declared or
initialized. If the answer is yes. You can say that the syntax is wrong. If the statement is
rewritten as: x< y? a: (b= p* q); the return value would be variable a because the x is 1 and
less than y = 2; the x < y statement return true and variable a is returned.
Collection and Organization by, Mr. Kute T. B. for TYIF (2008-2009)
- 1 -
Java and Advanced Java: Descriptive Questions and answers for Students.
Question: What is the difference between Swing and AWT components?
Answ er: AWT components are heavy-weight, whereas Swing components are lightweight.
Heavy weight components depend on the local windowing toolkit. For example,
java.awt.Button is a heavy weight component, when it is running on the Java platform for
Unix platform, it maps to a real Motif button.
Question: Why Java does not support pointers?
Answ er: Because pointers are unsafe. Java uses reference types to hide pointers and
programmers feel easier to deal with reference types without pointers. This is why Java and
C# shine.
Question: Parsers? DOM vs SAX parser
Answ er: parsers are fundamental xml components, a bridge between XML documents and
applications that process that XML. The parser is responsible for handling xml syntax,
checking the contents of the document against constraints established in a DTD or Schema.
Question: What is a platform?
Answ er: A platform is the hardware or software environment in which a program runs. Most
platforms can be described as a combination of the operating system and hardware, like
Windows 2000/ XP, Linux, Solaris, and MacOS.
Question: What are the main difference between Java platform and other platforms?
Answ er: The Java platform differs from most other platforms in that it's a software-only
platform that runs on top of other hardware-based platforms. The Java platform has two
components:
Question: What is the Java Virtual Machine?
Answ er: The Java Virtual Machine is a software that can be ported onto various hardware-
based platforms
Question: What is the Java API?
Answ er: The Java API is a large collection of ready-made software components that provide
many useful capabilities, such as graphical user interface (GUI) widgets.
Question: What is the package?
Answ er: The package is a Java namespace or part of Java libraries. The Java API is grouped
into libraries of related classes and interfaces; these libraries are known as packages.
Question: What is native code?
Answ er: The native code is code that after you compile it, the compiled code runs on a
specific hardware platform.
Question:Is Java code slower than native code?
Answ er: Not really. As a platform-independent environment, the Java platform can be a bit

slower than native code. However, smart compilers, well-tuned interpreters, and just-in-time byte code compilers can bring performance close to that of native code without threatening portability.

Collection and Organization by, Mr. Kute T. B. for TYIF (2008-2009)
- 2 -
Java and Advanced Java: Descriptive Questions and answers for Students.
Question: What is the serialization?
Answ er: The serialization is a kind of mechanism that makes a class or a bean persistence
by having its properties or fields and state information saved and restored to and from
storage.
Question: How to make a class or a bean serializable?
Answ er: By implementing either the java.io.Serializable interface, or the
java.io.Externalizable interface. As long as one class in a class's inheritance hierarchy
implements Serializable or Externalizable, that class is serializable.
Question: How many methods in the Serializable interface?
Answer: There is no method in the Serializable interface. The Serializable interface acts as a
marker, telling the object serialization tools that your class is serializable.
Question: . How many methods in the Externalizable interface?
Answer: There are two methods in the Externalizable interface. You have to implement these
two methods in order to make your class externalizable. These two methods are
readExternal() and writeExternal().
Question:What is the difference between Serializalble and Externalizable interface?
Answer: When you use Serializable interface, your class is serialized automatically by default.
But you can override writeObject() and readObject() two methods to control more complex
object serailization process. When you use Externalizable interface, you have a complete
control over your class's serialization process.
Question: What is a transient variable?
Answer: A transient variable is a variable that may not be serialized. If you don't want some
field to be serialized, you can mark that field transient or static.
Question:Which containers use a border layout as their default layout?
Answer: The Window, Frame and Dialog classes use a border layout as their default layout.
Question: How are Observer and Observable used?
Answer: Objects that subclass the Observable class maintain a list of observers. When an

Observable object is updated it invokes the update() method of each of its observers to notify the observers that it has changed state. Objects that observe Observable objects implement the Observer interface.

Question: What is synchronization and why is it important?
Answer: With respect to multithreading, synchronization is the capability to control the

access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often causes dirty data and leads to significant errors.

Question: What are synchronized methods and synchronized statements?
Answer: Synchronized methods are methods that are used to control access to an object. A
thread only executes a synchronized method after it has acquired the lock for the method's
object or class. Synchronized statements are similar to synchronized methods. A

Collection and Organization by, Mr. Kute T. B. for TYIF (2008-2009)
- 3 -

Activity (30)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Seema Shah liked this
chandrasekar C liked this
tapan_ghosh liked this
Mathu Krithigha liked this
Sreejith Tcv liked this
Arun Prakash liked this
pearl641 liked this
Hari Kanna liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->