Professional Documents
Culture Documents
(Insertion,
Selection, Exchange, Deletion)
Sorting is not possible in Deletion. Using insertion we can perform insertion sort, using
selection we can perform selection sort, using exchange we can perform the bubble sort (and
other similar sorting methods). But no sorting method can be done just using deletion.
6. In RDBMS, what is the efficient data structure used in the internal storage
representation?
B+ tree. Because in B+ tree, all the data is stored only in leaf nodes, that makes searching
easier. This corresponds to the records that shall be stored in leaf nodes.
7. Does the minimum spanning tree of a graph give the shortest distance between any
2 specified nodes?
No. The Minimal spanning tree assures that the total weight of the tree is kept at its
minimum. But it doesn't mean that the distance between any two nodes involved in the
minimum-spanning tree is minimum.
Path and Classpath are operating system level environment variales. Path is used define
where the system can find the executables(.exe) files and classpath is used to specify the
location .class files.
The variable should be declared as static and final. So only one copy of the variable
exists for all instances of the class and the value can't be changed also.
Yes. You can have any number of main() methods with different method signature and
implementation in the class.
It is a phenomenon in virtual memory schemes when the processor spends most of its time
swapping pages, rather than executing instructions. This is due to an inordinate number of
page faults.
Yes.
Increased speed and memory capacity of microprocessors together with the support
fir virtual memory and
Growth of client server computing
A constructor is a member function of a class that is used to create objects of that class. It
has the same name as the class itself, has no return type, and is invoked using the new
operator.
A method is an ordinary member function of a class. It has its own name, a return type (which
may be void), and is invoked using the dot operator.
The purpose of garbage collection is to identify and discard objects that are no longer
needed by a program so that their resources can be reclaimed and reused.
A Java object is subject to garbage collection when it becomes unreachable to the program
in which it is used.
Without synchonization, it is possible for one thread to modify a shared variable while
another thread is in the process of using or updating same shared variable. This usually
leads to significant errors.
Any class with an abstract method is automatically abstract itself, and must be declared as
such. A class may be declared abstract even if it has no abstract methods. This prevents it
from being instantiated.
An abstract class can have instance methods that implement a default behavior. An Interface
can only declare constants and instance methods, but cannot implement default behavior
and all methods are implicitly abstract.
An interface has all public members and no implementation. An abstract class is a class
which may have the usual flavors of class members (private, protected, etc.), but has
some abstract methods.
A final class can't be extended ie., final class may not be subclassed. A final method can't
be overridden when its class is inherited. You can't change value of a final variable (is a
constant).
The program compiles properly but at runtime it will give " main() method not public."
message.
What if the static modifier is removed from the signature of the main() method?
What if I do not provide the String array as the argument to the method?
Program compiles but throws a runtime error "NoSuchMethodError".
Yes it is possible. While starting the application we mention the class name to be run. The
JVM will look for the Main method only in the class whose name you have mentioned.
Hence there is not conflict amongst the multiple classes having main() method.
No the program fails to compile. The compiler says that the main() method is already
defined in the class.
A checked exception is some subclass of Exception (or Exception itself), excluding class
RuntimeException and its subclasses. Making an exception checked forces client
programmers to deal with the possibility that the exception will be thrown.
What is Overriding?
When a class defines a method using the same name, return type, and arguments as a
method in its superclass, the method in the class overrides the method in the superclass.
When the method is invoked for an object of the class, it is the new definition of the method
that is called, and not the method definition from superclass. Methods may be overridden to
be more public, not more private.
How can one prove that the array is not null but empty using one line of code?
Print args.length. It will print 0. That means it is empty. But if it would have been null then
it would have thrown a NullPointerException on attempting to print args.length.
Are the imports checked for validity at compile time? Example: will the code
containing an import such as java.lang.ABCD compile?
Yes the imports are checked for the semantic validity at compile time. The code containing
above line of import will not compile. It will throw an error saying, can not resolve symbol
No you will have to import the subpackages explicitly. Importing com.MyTest.* will import
classes in the package MyTest only. It will not import any class in any of it's subpackage.
In declaration we just mention the type of the variable and it's name. We do not initialize it.
But defining means declaration + initialization.
31 What is serialization?
Serialization is a mechanism by which you can save the state of an object by converting it to a
byte stream.
Java only supports pass by value. With objects, the object reference itself is passed by value and
so both the original reference and parameter copy both refer to the same object.
The initial configuration of the queue is a,b,c,d (a is the front end). To get the configuration
d,c,b,a one needs a minimum of ?
Linked list are not suitable data structure of which one of the following problems ?
Binary search
The number of possible ordered trees with three nodes A,B,C is? Ans 12
Which of the following algorithm design technique is used in the quick sort algorithm? Ans divide
and conquer
Given two sorted lists of size m and n respectively.The number of comparisons needed in the
worst case by the merge sort algorithm will be? Ans m+ n-1
Which of the following is useful in traversing a given graph by breadth first search? Queue
You can make telephone calls over the Internet using a technology called ? voip
17. Define latency, transfer and seek time with respect to disk I/O.
Seek time is the time required to move the disk arm to the required track. Rotational delay or
latency is the time it takes for the beginning of the required sector to reach the head. Sum of
seek time (if any) and latency is the access time. Time taken to actually transfer a span of
data is transfer time.
19.What is time-stamping?
It is a technique proposed by Lamport, used to order events in a distributed system without
the use of clocks. This scheme is intended to order events consisting of the transmission of
messages. Each system 'i' in the network maintains a counter Ci. Every time a system
transmits a message, it increments its counter by 1 and attaches the time-stamp Ti to the
message. When a message is received, the receiving system 'j' sets its counter Cj to 1 more
than the maximum of its current value and the incoming time-stamp Ti. At each site, the
ordering of messages is determined by the following rules: For messages x from site i and y
from site j, x precedes y if one of the following conditions holds....(a) if Ti<Tj or (b) if Ti=Tj and
i<j.
20 How are the wait/signal operations for monitor different from those for
semaphores?
If a process in a monitor signal and no task is waiting on the condition variable, the signal is
lost. So this allows easier program design. Whereas in semaphores, every operation affects
the value of the semaphore, so the wait and signal operations should be perfectly balanced
in the program.
In loading programs into memory, what is the difference between load-time dynamic
linking and run-time dynamic linking?
For load-time dynamic linking: Load module to be loaded is read into memory. Any
reference to a target external module causes that module to be loaded and the references
are updated to a relative address from the start base address of the application module.
With run-time dynamic loading: Some of the linking is postponed until actual reference
during execution. Then the correct module is loaded and linked.
With demand paging, a page is brought into memory only when a location on that page is
actually referenced during execution. With pre-paging, pages other than the one demanded
by a page fault are brought in. The selection of such pages is done based on common
access patterns, especially for secondary memory devices.
What are the four layers that Windows NT have in order to achieve independence?
The class whose instances are to be serialized should implement an interface Serializable. Then
you pass the instance to the ObjectOutputStream which is connected to
a fileoutputstream. This will save the object to a file.
The serializable interface is an empty interface, it does not contain any methods. So we do not
implement any methods.
33. How can I customize the seralization process? i.e. how can one have a control
over the serialization process?
Yes it is possible to have control over serialization process. The class should implement
Externalizable interface. This interface contains two methods
namely readExternal and writeExternal.
You should implement these methods and write the logic for customizing the serialization
process.