ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
What is meant by constructor?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is meant by constructor?
Answer
# 1
All the objects that are created must be given initial 
values.There are two approach for this.
1)Using the dot operator to access the instance variables 
and then assign values to them individually---This is a 
tedious approach.
2)Use of getData method to initialize each object 
individually.eg:add.getData(10,15)
To make this simpler Java supports a special type of method 
called a Constructor,that enables an object to initialize 
itself when it is created.Constructor have the same name as 
the class itself and they do not specify a return type,not 
even void,bcoz they return the instance of the class itself.
 
Is This Answer Correct ?    2 Yes 1 No
Dinesh
 
  Re: What is meant by constructor?
Answer
# 2
Constructor is special type of member function that will 
automatically invoke when an object creates. The purpose of 
constructor is for the initialization of instance 
variables. A constructor having the same name as that of 
class name. It may have arguments but doesn't return 
anything. 
  If we want to initialize all objects of the same class 
with same values, use default constructor.Otherwise, we can 
use parameterized constructor if we want to initialize 
objects of the same class with different values. If we 
don't specify any constructor , compiler will use default
constructor with garbage value.
 
Is This Answer Correct ?    7 Yes 0 No
Bindhu
 
 
 
  Re: What is meant by constructor?
Answer
# 3
constructor is the one which is used to pass the
initializing parameters during instantiation
 
Is This Answer Correct ?    1 Yes 1 No
Ravikiran(aptech Mumbai)
 
  Re: What is meant by constructor?
Answer
# 4
Constructor is defined as a type of member function which 
calls itself when an object is created also has the same 
name as of the class.
 
Is This Answer Correct ?    0 Yes 0 No
Ajay Yadav
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
what is the use of abstract class and interface with example? DNS2
Which is the best way to use for String concatenation in Java? HCL5
How many ways can an argument be passed to a subroutine?  2
What are the standards to place package statement within a source code file?  1
How can be define MARKER interfce in java  1
what is business objects?  1
What is the USE of Null interfaces ??...if thers nothing inside these interfaces how are they used and WHy are they used ???? No 1 has given a proper description yet  1
what is Hashmap & Hashtable wirh example? Saksoft4
my method "abc" return array of interface "xyz" and "pqr" is abstract class implements abc and class "jkl" extends pqr My problem 1) when i call abc it retrun array xyz how can i do this hint xyz refer_xyz = new jkl(); but i can't create array. 2)I want to access method of jkl using reference of xyz??  1
when we write class.forName("any one class"); what happens actually?what it will return?explain stepwise?  4
How to create two different thread class inside a main function?  1
Difference between String and StringBuffer. IBM3
how session will be expired? Infosys4
where do we use init()  2
Which class is extended by all other classes?  2
What is the differnence between String Buffer and String builder despite having knowledge that String builder is faster than String Buffer and last one is threadsafe.please tell another important difference.  3
What is the need to implement Serializable interface (with no methods) for objects which are to be serialized ? We can write our own functionality which writes objects to streams then why we need to implement and tell JVM that which objects can be serialized. iFlex4
Explain class A{} class B{} class C{} all the three classes are saved in a single file name, what the name should i provide to the file ,in what file name should i run the program? Ple Explain DNS6
Define interface?  2
Differentiate constructor and a method and how are it be used? Wipro5
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com