What will be the output of following quiz on implementing an interface? Answer This program will print “Test”. This code provides an anonymous implementation of IntfA and overrides its toString() method. You may also like Top 10 popular and tricky Java puzzles Top Java articles : March 2016 Best 25 …
Continue reading Java quiz on implementing InterfaceJava Quiz
What will be the output of following quiz on varargs? Answer Method name can be same as class name, although its not a good practice. If vararg parameter is present, it should be the last parameter in a method. So, the syntax is correct. vararg is internally represented as an array, so we …
Continue reading Java Quiz on varargsWhat will be the output of following quiz on Enum ? Answer The enum variable count is treated as an instance variable, not a static variable. The enum values Red, Green, Blue are all initialized at the same time. So, count = 0 for each of them Correct answer is “0” …
Continue reading Java Quiz on EnumWhat will be the output of following quiz that parses a String to Number using NumberFormat ? Answer parse() method in NumberFormat parses text from the beginning of the given string to produce a number. The method may not use the entire text of the given string. It will throw an exception …
Continue reading Java Quiz on parsing String to NumberWhat will be the output of following quiz on reading input data using Scanner ? Answer The while loop iterates over some data and prints if it finds a Boolean value. So, it prints true and false. But when it finds 0, the program never moves to next token since it is …
Continue reading Java quiz on reading Input data using Scanner