ALLInterview.com :: Home Page            
 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                      
Google
   
 
Categories >> Software >> Java Related >> Java J2EE >> Core Java
 
 


 

 
 Core Java interview questions  Core Java Interview Questions (1722)
 Advanced Java interview questions  Advanced Java Interview Questions (331)
 Swing interview questions  Swing Interview Questions (44)
 EJB interview questions  EJB Interview Questions (134)
 Servlets interview questions  Servlets Interview Questions (255)
 Struts interview questions  Struts Interview Questions (196)
 JDBC interview questions  JDBC Interview Questions (187)
 JMS interview questions  JMS Interview Questions (9)
 SunOne interview questions  SunOne Interview Questions (3)
 J2EE interview questions  J2EE Interview Questions (71)
 Weblogic interview questions  Weblogic Interview Questions (147)
 Websphere interview questions  Websphere Interview Questions (14)
 Java Networking interview questions  Java Networking Interview Questions (20)
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions (87)
Question
Can i have abstract class with no abstract methods?
 Question Submitted By :: Core-Java
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
Yes, we can have abstract class without abstract method.
Best example is HttpServlet
 
Is This Answer Correct ?    178 Yes 9 No
Poonam
 
Answer
# 2
yes we can have concreate method in the abstract class 
Is This Answer Correct ?    35 Yes 4 No
Santosh
 
 
 
Answer
# 3
yes, we can.To prevent a class from directly creating
objects, better declare them as abstract classes.
Eg: HttpServlet
 
Is This Answer Correct ?    31 Yes 1 No
Mandeswara Rao
 
Answer
# 4
yes we can have abstract class with out a abstract methods
but when u have a single abstarct method u r class must and
should be declared as Abstarct.
 
Is This Answer Correct ?    22 Yes 3 No
Aravind
 
Answer
# 5
An abstract class without any abstract methods should be a
rare thing and you should always question your application
design if this case arises. Normally you should refactor to
use a concrete superclass in this scenario.
One specific case where abstract class may justifiably have
no abstract methods is where it partially implements an
interface, with the intention that its subclasses must
complete the interface. To take a slightly contrived
motoring analogy, a Chassis class may partially implement a
Vehicle interface and provide a set of core methods from
which a range of concrete Vehicle types are extended.
Chassis is not a viable implementation of a Vehicle in its
own right, so a concrete Car subclass would have to
implement interface methods for functional wheels, engine
and bodywork.
 
Is This Answer Correct ?    10 Yes 0 No
Mohan Sahu
 
Answer
# 6
an abstract class contain the abstract methods and concerete
method
Abstract method:- are those method which have no body.

concrete Method:- are those method which have a body.

 
Is This Answer Correct ?    10 Yes 1 No
Kamruddin
 
Answer
# 7
HI All,

In Java there is very lovely concept related to Abstract
Class, keep this concept always in your mind i.e.
1) A class can be abstract "without any abstract method".
2) But if a single method is abstract you need to declare
your class as abstract this is mandatory but if class is
abstract then its not mandatory to have abstract methods
as mentioned above.
 
Is This Answer Correct ?    3 Yes 1 No
Manish Kushwaha
 
Answer
# 8
yes,please find the below example.

abstract class AbstractClass1 {
public void method1(){
System.out.println("inside method1...");
}
}
class AbstractClass2 extends AbstractClass1{
public void method2(){
System.out.println("inside method2...");
}
}
public class AbstractDemo {
public static void main(String[] args) {
AbstractClass2 a = new AbstractClass2();
a.method1();
a.method2();
}
}
 
Is This Answer Correct ?    1 Yes 0 No
Sitaram
 
Answer
# 9
I certainly agree with Manish Kushwaha You can have abstract class without any abstract method but if you have a single abstract method you are suppose to make that class abstract
This is what Sun says :
" An abstract class is a class that is declared abstract—it may or may not include abstract methods" (http://java.sun.com/docs/books/tutorial/java/IandI/abstract.html)
 
Is This Answer Correct ?    0 Yes 0 No
Darkeye
 
Answer
# 10
Yes, we can do it undoubtedly, in that case we restrict it
to make an object of it. Example.- HttpServlet
 
Is This Answer Correct ?    0 Yes 0 No
Saubhik
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
If there are two notepad opened and working on it . is this a process or thread? computer based Live Example to differentiate between Thread , Process , and Multi tasking ? Wipro 3
what is meant by serialization?   7
What is numeric promotion?   1
abstract class Demo { public void show() { System.out.println("Hello I am In show method of Abstract class"); } } class Sample extends Demo { public void show() { super.show(); System.out.println("Hello I am In Sample "); } } public class Test { public static void main(String[] args) { //I WANT TO CALL THE METHOD OF BASE CLASS IT IS POSSIBLE OR NOT CAN WE USE SCOPE RESOLUTION OPERATOR TO CALL OR JAVA NOT SUPPORTED THAT :: OPERATORE } }   3
Write a program that takes a 5 digit number and calculates 2 power that number and prints it.   1
How to declare unique ArrayList ? RMSI 6
Difference between canvas class & graphics class?   1
Difference between overloading and overridding?   4
When you say String is immutable, what do you mean by that? Say I have String s = "Ness" s= s+"Technologies"; What will happen? If the value gets appended, then what is the meaning of immutable here? Ness-Technologies 5
what is difference between prepare stetement and callable starement with example? CMC 1
Hi friends, i am new to java. can you explain how java is secured.   2
In real time project which driver did u use? What is the main functionality of the Prepared Statement? Photon 3
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright © 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com