| Back to Questions Page |
| Question |
Is ResultSet class? |
Rank |
Answer Posted By |
|
Interview Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer |
no ResultSet is interface  |
0 | P.sreekiran |
| |
| |
| Question |
Can we override static methods? |
Rank |
Answer Posted By |
|
Interview Question Submitted By :: Guest |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer |
no we cannot overriding the static methods .
if we override the static method it will gives error  |
0 | P.sreekiran |
| |
| |
| Answer |
Yes, V can override static methods
But overridding and overridden methods must static  |
0 | Venkateswara Reddy |
| |
| |
|
|
| |
| Answer |
yes ,we can override the static methods to a nonstatic or
static methods  |
0 | Karun |
| |
| |
| Answer |
YES, WE CAN OVERRIDE STATIC METHODS BY STATIC METHODS  |
0 | Guest |
| |
| |
| Answer |
yes ,we can override the static methods to static methods
only.
sorry for the previous my wrong answer.:((((  |
0 | Karun |
| |
| |
| Answer |
Yes, Static Methods can be overridden but it won't give
overridden behaviour. Overiding execution happens based on
the runtime object.  |
0 | N.suresh Babu |
| |
| |
| Answer |
It may seems to be overriding the static methods, but the
real fact is HIDING.
class Foo {
public static void classMethod() {
System.out.println("classMethod() in Foo");
}
public void instanceMethod() {
System.out.println("instanceMethod() in Foo");
}
}
class Bar extends Foo {
public static void classMethod() {
System.out.println("classMethod() in Bar");
}
public void instanceMethod() {
System.out.println("instanceMethod() in Bar");
}
}
class StaticHiding {
public static void main(String[] args) {
Foo f = new Bar();
f.instanceMethod();
f.classMethod();
when u run this program output will be:
instanceMethod() in Bar
classMethod() in Foo.
Here if u say it to be overriding then the
subclass ie., Bar class having static classMethod() should
be executed. But the fact here is Foo class static
classMethod() is executed.
So its method HIDING and not method
overriding..
I hope i have given answer to my best if
anyone feels wrong plz do post ur suggestions..  |
1 | Sadheez |
| |
| |
| Answer |
yes we can override static method but can not overload that
is called method hiding nt overloading.  |
0 | Neha Jain |
| |
| |
| Answer |
Neha,
I didn't get your answer.
You can overload as well as override static methods, but
only with static methods.
I have tried it and it is getting compiled.
Example is here.
*********************************************************
public class abc
{
public static void main(String args[])
{
}
public static void trss()
{
}
public static void trss(int i)
{
}
}
*********************************************************  |
0 | Yogesh Gandhi |
| |
| |
| Answer |
we cannot override a static method but we can overload a
static method.
Ex: override is not possible
class Foo {
public static void classMethod() {
System.out.println("classMethod() in Foo");
}
public void instanceMethod() {
System.out.println("instanceMethod() in Foo");
}
}
class Bar extends Foo {
public static void classMethod() {
System.out.println("classMethod() in Bar");
}
public void instanceMethod() {
System.out.println("instanceMethod() in Bar");
}
}
class StaticHiding {
public static void main(String[] args) {
Foo f = new Bar();
f.instanceMethod();
f.classMethod();
when u run this program output will be:
instanceMethod() in Bar
classMethod() in Foo.
Ex: overload is possible
public class abc
{
public static void main(String args[])
{
}
public static void trss()
{
}
public static void trss(int i)
{
}
}  |
0 | Madan Mohanp |
| |
| |
| Answer |
Thanks for addition.
You are correct.
Static method cannot be overridden.
Overloading of static methods is possible.  |
0 | Yogesh Gandhi |
| |
| |
| Answer |
dear yogesh
sory for wrong answer we can not override static method
with static method that known as method hiding.plz view
following example
Briefly, when you override a method, you still get the
benefits of run-time polymorphism, and when you hide, you
don't. So what does that mean? Take a look at this code:
class Foo {
public static void classMethod() {
System.out.println("classMethod() in Foo");
}
public void instanceMethod() {
System.out.println("instanceMethod() in Foo");
}
}
class Bar extends Foo {
public static void classMethod() {
System.out.println("classMethod() in Bar");
}
public void instanceMethod() {
System.out.println("instanceMethod() in Bar");
}
}
class Test {
public static void main(String[] args) {
Foo f = new Bar();
f.instanceMethod();
f.classMethod();
}
}
If you run this, the output is
instanceMethod() in Bar
classMethod() in Foo  |
0 | Neha Jain |
| |
| |
| Answer |
We can't override the static method we can only redefine
them  |
0 | Devender Negi |
| |
| |
| Answer |
Yes, We can! see Below---
public class Final1 {
public static void mone() {
System.out.println("Iam in final method of
super class");
}
}
public class Final extends Final1{
public static void mone() {
System.out.println("Iam in final method of
sub class");
}
public static void main(String a[]) {
Final f = new Final();
f.mone();
}
}  |
0 | Rambabu |
| |
| |
|
| |
|
Back to Questions Page |