can we make a class static without using static keyword?

Answers were Sorted based on User's Feedback



can we make a class static without using static keyword?..

Answer / rampoojan gupta

no without static key word not define the static class..

Is This Answer Correct ?    18 Yes 2 No

can we make a class static without using static keyword?..

Answer / mamta subramanian

We cannot declare any outer class as static. There would a
compiler error if we do so.
But if it is an inner class we can declare it as static.
and it act as a static object of outer class.

Is This Answer Correct ?    8 Yes 2 No

can we make a class static without using static keyword?..

Answer / shadab alam

yes we can make a class static without using static keyword
We can prove it by following program.

we konw that static member of a class can be accessed by
using the class name now I will do it without static
keyword specify in sub class

Like a.abc.add()
where a is class name and abc is also class name but
without static keyword.But it executed successfully.
this proves that inner class is a static class.


using System;
static class a
{



public static void my()
{
Console.WriteLine("outer class's method");
}
class abc
{


public static void add()
{
Console.WriteLine("Inner class's
method");
}
}
public static void Main()
{

a.my();
a.abc.add();
}


}

Is This Answer Correct ?    6 Yes 3 No

can we make a class static without using static keyword?..

Answer / darwin

no not at all possible with this present java framework
format.. it coukd be possible only in future if they
enhances that option to do so.. and additionallly no outer
class can be static. you can also check by compiling in
java compiler...

Is This Answer Correct ?    1 Yes 0 No

can we make a class static without using static keyword?..

Answer / raja

see Shadab Alam, let me clear,first of all an outer class
can't be a static it could be either public or abstract or
final only, unfortunately Java Compiler can't allow other
than these three, so we can make any inner class as static.

and we can't make the behaviour of a class as static
without using "static" keyword. Thank u for asking this one.

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More OOPS Interview Questions

swapping program does not use third variable

5 Answers   TCS,


What is a class oop?

0 Answers  


What is polymorphism programming?

0 Answers  


What is a class?

32 Answers   Infosys, TCS, Thylak,


c++ program to swap the objects of two different classes

0 Answers  






Out of 4 concepts, which 3 C++ Follow?

1 Answers   TCS,


#include <stdio.h> #include <alloc.h> #include <stdlib.h> #include <conio.h> void insert(struct btreenode **, int); void inorder(struct btreenode *); struct btreenode { struct btreenode *leftchild; struct btreenode *rightchild; int data; }; main() { struct btreenode *bt; bt=(struct btreenode *)NULL; int req,i=1,num; clrscr(); printf("Enter number of nodes"); scanf("%d",&req); while(i<=req) { printf("Enter element"); scanf("%d",&num); insert(&bt,num); i++; } inorder(bt); } void insert(struct btreenode **sr, int num) { if(*sr==NULL) { *sr=(struct btreenode *)malloc (sizeof(struct btreenode)); (*sr)->leftchild=(struct btreenode *)NULL; (*sr)->rightchild=(struct btreenode *)NULL; (*sr)->data=num; return; } else { if(num < (*sr)->data) insert(&(*sr)->leftchild,num); else insert(&(*sr)->rightchild,num); } return; } void inorder(struct btreenode *sr) { if(sr!=(struct btreenode *)NULL) { inorder(sr->leftchild); printf("\n %d",sr->data); inorder(sr->rightchild); } else return; } please Modify the given program and add two methods for post order and pre order traversals.

0 Answers  


What are classes oop?

0 Answers  


What is polymorphism in oops?

0 Answers  


What is memory leak and memory corruption?

1 Answers   TCS,


What is destructor in oop?

0 Answers  


Program to check whether a word is in all capital letters

1 Answers  


Categories