- Explain OOP's concepts in java?
- In what cases you will use Abstract Class and Interfaces?
- What is stack and heap meamory in java?
- What is runtime exceptions? Give some examplls?
- Write a actual singleton java class?
- Wite a program to print the given array in reverse order {2,5,3,1,4} ?
- What is the difference between sleep() and wait() methods?
- What is the difference between ThreadClass and Runnable interface in Java?
- Explain Servelt life cycle ?
- Difference between forward() and sendRedirect() ?
- How JSP handle runtime Exceptions?
- Why hibernate?, Why not JDBC?
- What is the importance of SessionFactory in Hibernate?
- Difference between merge() and Update() methods?
- What is Secondarylevel cache in hibernate?
Showing posts with label core java concepts ppt. Show all posts
Showing posts with label core java concepts ppt. Show all posts
Important Java Interview Questions
Garbage Collector is controlled by whom?
Posted in: core java concepts ppt
The JVM controls the Garbage Collector; it decides when to run the
Garbage Collector. JVM runs the Garbage Collector when it realizes that
the memory is running low, but this behavior of jvm can not be
guaranteed.
One can request the Garbage Collection to happen from within the java program but there is no guarantee that this request will be taken care of by jvm.
One can request the Garbage Collection to happen from within the java program but there is no guarantee that this request will be taken care of by jvm.
What is Polymorphism?
Posted in: 15 Most Java Interview Questions for Experienced professionals.,85 Most Important Javascript Interview Questions,core java concepts ppt,FAQ's
Polymorphism is an important Object oriented concept and widely used in Java and other programming language. Polymorphism in java is supported along with other concept like abstraction, encapsulation and inheritance. bit on historical side polymorphism word comes from ancient Greek where poly means many so polymorphic are something which can take many form. In this java polymorphism tutorial we will see what polymorphism in Java is, how polymorphism is implemented in Java, why should we use polymorphism and how can we take advantage of polymorphism while writing code in Java. Along the way we will also see a real world example of using polymorphism in Java.
Constructors in Java Tutorial
Posted in: Core Java,core java concepts ppt,Hibernate,Hibernate Query examples (HQL),J2EE Design Patterns
What is Constructor in Java?
- Constructor is a special method that gets invoked “automatically” at the time of object creation.
- Constructor is normally used for initializing objects with default values unless different values are supplied.
- Constructor has the same name as the class name.
- Constructor cannot return values.
- A class can have more than one constructor as long as they have different signature (i.e., different input arguments).
If Constructor not defined in the class?
- If you don’t define a constructor, a default one(Zero Argument constructor) will be created by Java compiler.
- If you define any constructor for your class, no default constructor is automatically created.
Sample Examle :
public class ClassName {
// Data Fields…
// Constructor
public ClassName()
{
// Method Body Statements initialising Data Fields
}
//Methods to manipulate data fields
}
- We can call one constructor from another using this().
- Use this to call other constructors in the same class.
this( ) :
- Use this to refer to the current object.
- Use this to invoke other constructors of the object.
public class HelloWorld
{
int i ;
String str;
HelloWorld()
{
this(2);
}
HelloWorld(int i){
this("Hai");
this.i = i;
}
HelloWorld(String str){
this.str = str;
System.out.println(str + "Welcome!!!!");
}
}How to Call Super Class constructor ?
- we can call superclass constructor Using super() keyword
- super needs to be the first line of code in the constructor of the child class.
class Base
{
Base()
{
System.out.println("Hello i'm a super class Zero Arg Constructor");
}
Base(int i)
{
System.out.println("Hello i'm a super class Arg Constructor");
}
}
class Der extends Base
{
Der()
{
super(); //Automatically call if you don't call constructor here.
System.out.println("Sub class constructor");
}
Der(int j){
super(4);
System.out.println("Hai");
}
}
Differences between method and constructor
- There is no return type given in a constructor signature (header). The value is this object itself so there is no need to indicate a return value.
- There is no return statement in the body of the constructor.
- The first line of a constructor must either be a call on another constructor in the same class (using this), or a call on the superclass constructor (using super). If the first line is neither of these, the compiler automatically inserts a call to the parameterless super class constructor.
Differences between super() and this()
- "this" refers to the current class where as "super" refers directly to its immediate above super class.
- this() can be used to invoke a constructor of the same class.super() can be used to invoke a super class constructor
Other Java Tutorials you may like