hi to all,i have a question on static block.
i saved below as test.java
class test extends a
{
static {
System.out.println("test static");
}
public static void main(String []dfs)
{
}
}
class a
{
static
{
System.out.println("a static");
}
public static void main(String []asdf)
{
}
}
o/p
as static
test static
but if i change base class as test class then
class test
{
static {
System.out.println("test static");
}
public static void main(String []dfs)
{
}
}
class a extends test
{
static
{
System.out.println("a static");
}
public static void main(String []asdf)
{
}
}
o/p
test static
explain me why "a static" wasn't print in second code when
it is in derived class
just chek again ur code
class test extends a
{
static {
System.out.println("test static");
}
public static void main(String []dfs)
{
}
}
class a
{
static
{
System.out.println("a static");
}
public static void main(String []asdf)
{
}
}
it;s genrate the o/p
a static
class test
{
static {
System.out.println("test static");
}
public static void main(String []dfs)
{
}
}
class a extends test
{
static
{
System.out.println("a static");
}
public static void main(String []asdf)
{
}
}
test static
a static
ok jst analyze ur problem thn contact me
ashish.gupta126126@gmail.com
Is This Answer Correct ? | 0 Yes | 2 No |
How a class can implement an interface?
What about abstract classes in java?
What is user defined exception?
Is arraylist a class in java?
What do you mean by constant time complexity?
Explain the difference between an Interface and an Abstract class?
What is an Exception ?
Is set sorted in java?
How u dubugg ur project?
How do I remove a character from a string in java?
What is a finally block? Is there a case when finally will not execute?
What methodology can be utilized to link to a database?