The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 4 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Fullscreen Pageflip Layout with BookBlock
public class Quiz {
public static void main(String[] args) {
String s = null;
if (s.length() > 0) {
System.out.println(s);
} else {
System.out.println("empty string");
}
}
}
Which of the following statement best characterizes the above Java program:
public Quiz.java:4: variable s might not have been initialized
if (s.length() > 0) {
^
1 error
Exception in thread "main" java.lang.NullPointerException at Quiz.main(Quiz.java:4)
-----------