Why Static variable required in java?For ex,class A
{
static int a;
int b;
}
Why static is required?
Answer Posted / aswini
Without using instance of the class means no need to use the class object to call static variable insted directly use the classname to use the static variable.moreover ,only one copy of static varible avaible to use all the classes.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What are wrapper classes in java?
Write code to implement bubble sort in java?
Can we catch more than one exception in single catch block?
What is the difference between method overriding and overloading?
Why do we declare a class static?
What is a protected method?
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
What are static initalizers in java ?
Can finally block be used without a catch?
State the main difference between c++ and java?
How variables are declared?
what are different ways in which a thread can enter the waiting state? : Java thread
What's the difference between an abstract class and interface in java?
make a method which any number and any type of argument and print sum of that arguments.....
What is canonical name in java?