| Back to Questions Page |
| |
| Question |
can a static method be overridden
|
Rank |
Answer Posted By |
|
Question Submitted By :: Ravi |
| This Interview Question Asked @ SolutionNET |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | any one reply the answer with ex  |
| Ravi |
| |
| |
| Answer | Static method will be represented by class, not by objects.
Overriding technique will be for objects; Even if we have
same method in the sub class also that will be a static
method for that class  |
| Rama Devi |
| |
| |
| Answer | Hi rama devi,u are written the answer is ok but not clear
i given one example of this
what i am saying is the static methods are not overriden
cause the class loader will load the while loading the
class at runtime so the compiler will check the which
static method would i need to call co its confused thas's
why the static methods are not overriden.
EXAMPLE:
class A {
static void something () {}
}
class B extends A {
static void something () {}
}
....
A anA = new B ();
anA.something ();
think and compile what's the comipler say's.  |
| Narasimha Rao Bodagala |
| |
| |
|
|
| |
| Answer | Hi, Narasimha Rao Bodagala
I didnt get u. can u please explain once?  |
| Sandya |
| |
| |
| Answer | static method can be overridden  |
| Gaythri |
| |
| |
| Answer | public class Test extends Test2{
public static void main(String args[]){
String str="";
int b=Test.cal(4);
System.out.println(b);
Test t =new Test();
t.displayX();
}
public static int cal(int a){
int b=a*a;
return b;
}
}
public class Test2 {
public static void main(String args[]){
}
public static int cal(int a,int b){
int c=a*b;
System.out.println("IN Super orerriden
methods:");
return c;
}
public void displayX(){
System.out.println("HI i am in Super");
}
}
my Sub Class is Test extends Test2 Class
Common static method is cal()
its run properly. No compile error , NO runtime error  |
| Aswini De |
| |
| |
| Answer | Hi, Aswini ur program is wrong, there is no relation btween
cal methods in ur program, overriding means there must be
same no of arguments,there is a change in no of argumetns
in ur program.
static methods can not be overridden
ex:
main method is static, we can overload it but we can not
override it.  |
| Srinivas Katta |
| |
| |
| Answer | Hi, Srinivas.....in the above program posted by Aswini...I
think main() method is overridden....right?.....then we can
say static methods can be overridden....
Eg:
class Parent
{
public static void myStaticMethod()
{
System.out.println("A");
}
public void myInstanceMethod()
{
System.out.println("B");
}
}
public class Child extends Parent
{
public static void myStaticMethod()
{
System.out.println("C");
}
public void myInstanceMethod()
{
System.out.println("D");
}
public static void main(String[] args)
{
Parent o1 = new Parent();
Child o3 = new Child();
Parent.myStaticMethod(); // A
Child.myStaticMethod(); // C
o1.myStaticMethod(); // A
o1.myInstanceMethod(); // B
o3.myStaticMethod(); // C
o3.myInstanceMethod(); // D
}
}
In the above program myStaticMethod() is
overridden.....which is a static method.....  |
| Karteek |
| |
| |
| Answer | Static methods CANNOT be overridden as they belong to a
class and not an instance of the class.
Aswini De: First of all, you didnot override the cal method.
Karteek: In your example, the fact that
parent.mystaticMethod and child.mystaticmethod are printing
different answers is in itslef an indication that the method
is not overridden!!
-kk  |
| Kiran Kadarla |
| |
| |
| Answer | An instance method can not override the static method of
its parent class.like
if parenet class contains
public static void test()
{
}
then in child class you can't override like this
public void test(){ //you can't override
}
or even like this
public static int test(){ //compile time error:type is
incompatibe with parent's test method.
}  |
| Abid Mehmood |
| |
| |
| Answer | only static method in a subclass can over ride the static
method in the parent class.
for example
public class A {
public static int display(){
System.out.println("i an in A");
return 1;
}
}
public class B extends A{
public static int display(){
System.out.println("i an in B");
return 1;
}
/*public int display(){
}*/
}
will work fine. but if the subclass tries to override parent
class static method with a non static method it generates
compilation error.
for eg
public class B extends A{
/* public static int display(){
System.out.println("i an in B");
return 1;
}*/
public int display(){
}
}
the above code will result in compilation error.  |
| Mayank |
| |
| |
| Answer | @ Mayank
Static methods are *NEVER* ever be overridden, even if you
try to override a static method of the super class in your
subclass, it will compile because in this you are simply
redeclaring the static method of your superclass in your
subclass. Redeclaring a method is not the same as overriding
a method.
The bottomline is
** STATIC METHODS CAN NEVER BE OVERRIDDEN **  |
| Partha |
| |
| |
| Answer | yes main method can be override example
class mad
{
public static void main(String args[])
{}
}
public class mohit extends
{
public static void main(String args[])
{
System.out.println("HELLO");
}}
output HELLO
ANY question contact me with our email.my id.
mohit_kaushik1234@rediff.com  |
| Mohit Kaushik |
| |
| |
| Answer | Static methods are not overriden, they are hidden by static
method in subclass. Check out the link:
http://www.xyzws.com/javafaq/can-static-methods-be-overridden/1  |
| Nitasha |
| |
| |
| Answer | static method can be overriden. that is true  |
| Mohit |
| |
| |
| Answer | * STATIC METHODS CANT BE OVERRRIDDEN....*
class Animal {
static void doStuff() {
System.out.print("a ");
}
}
class Dog extends Animal {
static void dostuff() { // it's a redefinition,
// not an override
System.out.print("d ");
}
public static void main(String [] args) {
Animal [] a = {new Animal(), new Dog(), new Animal()};
for(int x = 0; x < a.length; x++)
a[x].doStuff(); // invoke the static method
}
}
Running this code produces the output:
a a a  |
| Let The Code Speaks.... |
| |
| |
| Question |
diff vector arraylist |
Rank |
Answer Posted By |
|
Question Submitted By :: Ravi |
| This Interview Question Asked @ Saka-Solutions |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | 1) Arraylist is not synchronised while vector is
synchronised.
2) ArrayList doesn’t have a constructor for specifying the
incremental capacity, where as Vector has a constructor to
specify the initial capacity and incremental capacity.
3) Vector is serialized but arraylist is not.  |
| Chandra |
| |
| |
| Answer | Both classes are serializable.See the java doc for
clarification.
Please dont misguide readers  |
| Lipu |
| |
| |
| Question |
whether the connectionpooling used in struts? |
Rank |
Answer Posted By |
|
Question Submitted By :: Ravi |
| This Interview Question Asked @ SolutionNET |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Connection polling is nothing but , group of database
connection whichs are maintain and reuse and if no loger
use the remove, is a technique , connection polling
technique release in JDBC 2.0 - optional package, another
Optional API is data base connection using JNDI, instead of
DriverManager  |
| Aswini De |
| |
| |
| Question |
how the mapping can be done from jsp to actionservlet? |
Rank |
Answer Posted By |
|
Question Submitted By :: Ravi |
| This Interview Question Asked @ SolutionNET |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Through config file
in Struts we have to load the frmework config file
struts-config.xml
in this file we have to configure the particular jsp to
land the request on action servlet, default ActionServlet
is unique in struts framework  |
| Satya |
| |
| |
| Question |
explain the flow of struts? |
Rank |
Answer Posted By |
|
Question Submitted By :: Ravi |
| This Interview Question Asked @ SolutionNET |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | a)Client makes a Http Request.
b)Every request has to go to the ActionServlet which
actually is the Front Controller of Struts.
c)ActionServlet calls the Request Processor for execution
of the request.
d)Request Processor reads the xml file (Struts-config.xml)
where the mappings have been provided for each and every
request and finds out the corresponding Action Class
mapping to that request.
(1)How the mappings are provided in Struts-Config.xml
file will be discussed under Configuring Recipe Module.
e)Before passing the control to the execute() method of the
Action Class, it instantiates the Form Bean associated with
that Action Class.
f)Once the Action Form/ Form Bean is instantiated, control
goes to execute() method of Action Class.
g)Action Class then call the Business Layers to fetch the
data requested by the client.
h)Once the data is fetched, it is populated in the Form
Bean and control goes back to Action Class.
i)And finally, Action Class throws the control to JSP page
where the data is rendered.
j)To render the data on JSP page, data is taken out of Form
Bean with the help of Struts Tags.
k)Struts provides us with various Tag Libraries which makes
the JSP page easy to create and maintain.
l)JSP Tags will be discussed later.
 |
| Kumar S |
| |
| |
| Answer | Answer is correct,Need some explanation along with examples
for configuration xml and all.  |
| Pavankumar |
| |
| |
| Question |
diff between jsp include directive and jsp action include? |
Rank |
Answer Posted By |
|
Question Submitted By :: Ravi |
| This Interview Question Asked @ SolutionNET |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | jsp include directive --its cal at d translation time,
jsp action include---its cal at runtime  |
| Soori |
| |
| |
| Answer | diff between jsp include directive and jsp action include:
1)syntax of inclde directive<%@ include file="filename"%>
syntax of inclde action<jsp:include page="filename">
2)inclde directive : done when compilation time
inclde action: done when requestprocessing time
3)inclde directive: included content is static
inclde action:included content is static or dyanamic  |
| Bhudeep |
| |
| |
| Question |
difference between applicationserver and webserver |
Rank |
Answer Posted By |
|
Question Submitted By :: Ravi |
| This Interview Question Asked @ SolutionNET |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | web server allows only HTTP protocal(i.e Protocal dependent)
But App Server Protocal independent
web server is less secure than app sever  |
| Venkat |
| |
| |
| Answer | Web Server is used to render mostly static content (html
pages), while app server is capable of offering more
services like execution of dynamic pages (jsp,servlets) and
offeres many out of box infrastructure components like
security, transaction handling, database connectivity, and
many other services.
WebServer and Appservers can be on different boxes to
improve performance in Ntier architecture.  |
| Veeru |
| |
| |
|
| |
|
Back to Questions Page |