Java Language Interview Question and Answers

46. When is a method said to be overloaded and when is a method said to be overridden?
  Overloading deals with multiple methods in the same class with the same name but different method signatures.
Overriding deals with two methods, one in the parent class and the other one in the child class and has the same name and signatures.
 
Your Name Your Email-ID
Your Answer
47. How is final different from finally and finalize()?
 
  • Final - constant declaration.
  • The finally block always executes when the try block exits, except System.exit(0) call.
  • finalize() is a method of Object class which will be executed by the JVM just before garbage collecting object to give a final chance for resource releasing activity.
 
Your Name Your Email-ID
Your Answer
48. What is Byte Code?
  All Java programs are compiled into class files that contain bytecodes. These byte codes can be run in any platform and hence java is said to be platform independent.
 
Your Name Your Email-ID
Your Answer
49. What is the difference between error and an exception?
  Exception means When a method encounters an abnormal condition (an exception condition) that it can’t handle itself, it may throw an exception.
ssError mens system doesn’t handle.For example:Overflow,Out of memory.
 
Your Name Your Email-ID
Your Answer
50. What if the main method is declared as private?
  When a method is declared as private, the program compiles properly but it will give runtime error Main method not “public„.
 
Your Name Your Email-ID
Your Answer
123456789101112 Page 10 of 12