What Is Pass by Value, Pass by Reference?: Hashtable
What Is Pass by Value, Pass by Reference?: Hashtable
Hashtable : It is very much similar to hashMap if compared as it also stores the key/value pairs in the
table. While Using this we can mention an object that is used as a key, and the value that we want
linked to that key. The key is then hashed, and the resulting hash code is used as the index at which the
value is stored within the table.
Properties: It is a subclass of Hashtable. It is used to maintain lists of values in which the key is a String and
the value is also a String. It defines the following instance Variable: Properties defaults; It holds a default
property list which is related with a Properties Object.
Properties defines these two constructors:
Java Vectors. It implemnts a dynamic array very much similar to the ArrayList.It has few differences as it is
synchronized and conatins many legacy methods. It basically extends the AbstractList Class and implemnts
the List Interface. }
Stack: It is a sub class of Vector which implements a standard last-in, first-out stack.It defines only a default
constructor which creates an empty Stack and it includes all the methods defined by vector. We can call pop (
) method to remove and return the top. An EmptyStackException is thrown if you call pop( ) when the
invoking stack is empty. We can use peek( ) to return, but not remove, the top object.
What is collection and what are the collections that you have used ?
A collection — sometimes called a container — is simply an object that groups multiple elements into a single
unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data
A collections framework is a unified architecture for representing and manipulating collections. All
collections frameworks contain the following:
Interfaces: These are abstract data types that represent collections. Interfaces allow collections to be
manipulated independently of the details of their representation. In object-oriented languages,
interfaces generally form a hierarchy.
Implementations: These are the concrete implementations of the collection interfaces. In essence, they
are reusable data structures.
Algorithms: These are the methods that perform useful computations, such as searching and sorting,
on objects that implement collection interfaces. The algorithms are said to be polymorphic: that is, the
same method can be used on many different implementations of the appropriate collection interface.
In essence, algorithms are reusable functionality.
What is polymorphism?
Polymorphism is one name in many forms ,we can use same name with different parameters for methods .
example is method overloading and method overriding
Polymorphism is briefly described as "one interface, many implementations."
There are two types of polymorphism one is Compile time polymorphism and the other is run time
polymorphism. Compile time polymorphism is method overloading. Runtime time polymorphism is done
using inheritance and interface.
Note: From a practical programming viewpoint, polymorphism manifests itself in three distinct forms in Java:
Method overloading
Method overriding through inheritance
Method overriding through the Java interface
Difference between static class and final class?Is Static class inheritable?
Static classes are inheritable.Simply put the keyword static in the declaration of the methods in the class. The
declaration of the class itself requires no special decoration. The class can contain static and non-static
methods and properties simultaneously.
final classes are not inheritable we can declare class as final by using final key word
What is thread?
A thread is an independent path of execution within a program
Every thread in Java is created and controlled by the java.lang.Thread class. A Java program can have many
threads, and these threads can run concurrently, either asynchronously or synchronously.
package com;
import java.util.Vector;
public class MethodOverLoad {
void display(String msg){
System.out.println("String parameter method::"+msg);
}
void display(Vector vmsg){
System.out.println("vector method call::"+vmsg);
}
public static void main(String args[]){
MethodOverLoad mol =new MethodOverLoad();
mol.display(null);
}}
What will be the output of above programme ?
Compilation error
The method display(String) is ambiguous for the type MethodOverLoad
Which will handle the ioexception if a catch block contain Exception followed by IOException? where
would control go if it also have a finally block.
It goes to finally block
Consider a super class object as A and subclass object as B then A=B is correct or not?
No
What is Reflection?
Reflection is a feature in the Java programming language. It allows an executing Java program to examine or
"introspect" upon itself, and manipulate internal properties of the program. For example, it's possible for a Java
class to obtain the names of all its members and display them.
What is static?
Static is key word , jvm will executes static blocks whit out creating object. We can access static variables and
methods by using class name.
What types of access modifiers are eligible for variables declared inside a method?
Public,private,protected,final