Which of the following is a valid way to declare a variable in Java?
What will be the output of the following code?
Java
public class Geeks {
public static void main(String[] args) {
int a;
System.out.println(a);
}
}
Which of the following is true about variable names in Java?
Variable names can start with a number
Variable names can contain special characters like @ or #
Variable names are case-sensitive
Variable names can be a Java keyword
What is the default value of a boolean instance variable in Java?
What will be the output of the following Java program?
Java
public class Main {
static int x;
public static void main(String[] args) {
System.out.println(x);
}
}
What is the correct way to declare a constant variable in Java?
What will be the output of this code?
Java
public class Example {
int num = 5;
public static void main(String[] args) {
Example obj = new Example();
System.out.println(obj.num);
}
}
Which of the following statements about var keyword is FALSE?
var can be used for local variables
var can be used for instance variables
var must be initialized at the time of declaration
var is introduced in Java 10
What will be the output of this Java program?
Java
public class Demo {
public static void main(String[] args) {
int x = 10;
{
int x = 20;
System.out.println(x);
}
}
}
Which of the following statements is correct?
Static variables are shared among all objects of a class
Local variables are automatically initialized
Instance variables cannot be final
A final variable can be reassigned
There are 10 questions to complete.
Take a part in the ongoing discussion
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4