| Back to Questions Page |
| |
| Question |
If all the methods in abstract class are declared as
abstract then what is difference between abstract class and
in interface? |
Rank |
Answer Posted By |
|
Question Submitted By :: Namita |
| This Interview Question Asked @ Synechron |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | In abstract class concrete methods are also there. concrete
methods are the one which has implementation. so in future
if any programmer wants to give concrete methods can use
abstract class not interface.
In abstract class for methods and variables
public,private,protected modifier can be use. but in
interface public and abstract are permitted.  |
| Namita |
| |
| |
| Question |
Can we write a constructor for a Servlet class ? if yes how ?
if no why not ? |
Rank |
Answer Posted By |
|
Question Submitted By :: Suryakanth |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | you can write as like for regular class.  |
| Abc |
| |
| |
| Question |
public class Garbage
{
int a=0;
public void add()
{
int c=10+20;
System.out.println(c);
System.out.println(a);
}
public static void main(String args[])
{
Garbage obj=new Garbage();
System.gc();
System.out.println("Garbage Collected");
obj.add();
}
}
Above is a code in java used for garbage collection. object
obj has been created for the class Garbage and system.gc
method is called. Then using that object add method is
called.System.gc method if called the obj should be garbage
collected? |
Rank |
Answer Posted By |
|
Question Submitted By :: Maverickhari |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | First We cannot force the garbage collection to garbage the
object. Garbage collection can never be forced.
So by calling System.gc() will not ensure you that the
object will be garbage collected.  |
| Namita |
| |
| |
|
|
| |
| Answer | say me when this eill actually happen.  |
| Maverickhari [HCL] |
| |
| |
| Answer | Maverickhari,
Garbage collector is system created thread which runs
automatically.
We are not sure when the garbage collection is going to
happen. this totally depends upon the JVM. Like connection
pool all the the objects are created in pool JVM will check
if there is no free memory in pool then it searches for the
objects which are no longer in use and will garbage collect
that and allocate to some other object.
hope this will clear  |
| Namita [HCL] |
| |
| |
| Question |
What is the use of log4j and how to make use of
that in a application? |
Rank |
Answer Posted By |
|
Question Submitted By :: Mahender |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | log4j can be used for writing the log messages to various
kinds of destinations like a file, database, console etc...
It is always advisable to use some sort of logging API to
generate the log messages.the log messages helps the end
user as well as the developer of the application, to kow
about what the application has done and why the application
has failed, etc...
It is developed by Apache and this is used as part of
various products like hibernate, struts, strings etc...  |
| Suresh Gangula |
| |
| |
| Question |
important features of java which differenciate it from c++ |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Java is apure object-oriented progrmaing language.here one
beter feature we have i.e multiple inheritance and pointer
concepets are not used.
In java the primitivw datatypes like(int,float,double,short)
these values can be represented in objects of classes.  |
| Sureshyadav |
| |
| |
| Answer | there are following diff between java and c++
1) one of the most important diff is there is no pointre in
java but pointer is hidden from programmer.
2) java is pure object oriented programming language where
as c++ is not pure object oriented language is also support
c feature.
3) in java everything should be within class includin main
function where as it can be in calss or not.
4) java doesn't support operator overloading where as c++
souuprt
5)there is no global variable in java where as it is in c++
6) there is no distructor in java but threr is finally key
work
7)there is no multipal inharitance but is can be achived by
interface  |
| Kumod Kumar |
| |
| |
| Answer | there are following diff between java and c++
1) one of the most important diff is there is no pointre in
java but pointer is hidden from programmer.
2) java is pure object oriented programming language where
as c++ is not pure object oriented language is also support
c feature.
3) in java everything should be within class includin main
function where as it can be in calss or not.
4) java doesn't support operator overloading where as c++
souuprt
5)there is no global variable in java where as it is in c++
6) there is no distructor in java but threr is finally key
work
7)there is no multipal inharitance but is can be achived by
interface  |
| Kumod Kumar |
| |
| |
| Question |
Is it compulsory to have atleast one abstract method in
abstract class?
|
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | yes it is very much compulsory to have a one abstract mthod
in abstract class
otherwise will be no longer abstract  |
| Krishna |
| |
| |
| Answer | No. It is not compulsory that an abstract class
should have atleast one abstract method.
One can declare a class as abstract still with full
implementation of methods. This avoids the instantiation
the class  |
| Chellammal |
| |
| |
| Answer | No,It is not mandatory, but sub class of abstract class
should be override by any one of the method from abstract
class .
Ex:i) javax.servlet.http.HttpServlet
ii) org.apache.struts.actions.DispatchAction, etc.,  |
| Chandrasekhar.k |
| |
| |
| Question |
diff between abstract methods and interfaces with programing
(code) example? |
Rank |
Answer Posted By |
|
Question Submitted By :: Chandan61 |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | an abstract class contains the concrete methods as well
abstract methods. It may instance variables and static
final variables
an interface contains only abstract methods. all the
variables are by default static and final.
an abstract class contains constructor where as an
interface does not have constructors...  |
| Naresh P |
| |
| |
| Answer | abstract class A
{
protected abstract void show();
}
public class xx extends A
{
protected void show()
{
System.out.println("karthik ok");
}
static void main(String aa[])
{
xx ob=new xx();
ob.show();
}
}
But in Interface
interface A
{
protected abstract void show();
}
public class xx implements A
{
protected void show()
{
System.out.println("karthik ok");
}
static void main(String aa[])
{
xx ob=new xx();
ob.show();
}
}
modifier protected not allowed here
protected abstract void show(); in Interface
Because Default public method
But in Abstract class we can have protected
interface A
{
int x;//Error we should need initial value
}  |
| Karthik [Enntech4] |
| |
| |
|
| |
|
Back to Questions Page |