Answer Posted / satish
Direct global variables are not possible like
int i=0;
class{
....
....
}
But other way is create a class with static variables and
you can use it wherever needed.
class Global{
public static int i;
public static String s="";
}
class SomeClass{
public static void main(String args[]){
Global.i=23;
Global.s="Whats up"
}
}
| Is This Answer Correct ? | 6 Yes | 2 No |
Post New Answer View All Answers
What do you understand by classes in java?
What are the files generated after using IDL to java compiler?
Mention a package that is used for linked list class in java.
What will happen if static modifier is removed from the signature of the main method?
What is the use of parseint in java?
Is call by reference possible in java?
why doesn't java run on all platforms?
23. Storage space in java is of the form Stack Queue Heap List 24. What is java code embedded in a web page known as Applets Servlets scriptlets snippets 25. Which of the following attributes are compulsory with an
What is a two-pass assembler?
What is a stringbuilder?
What do you know about the garbate collector?
Why is sizeof not a function?
Can a boolean be null java?
How do you find the independent variable?
How many static init can you have?