Core Java Interview Questions and Answers Hi guys, I am attempting to put as many of Core Java interview questions and answers as possible in this post. You can bookmark this post as the no. of questions here will increase over time as I keep updating them. Q.1 How is Java platform independent? Ans: Before going into the detail,first you have to understand what is the mean of platform? Platform consists of the computer hardware(mainly architecture of the microprocessor) and OS. Platform=hardware+Operating System Anything that is platform independent can run on any operating system and hardware. Java is platform indepedent so java can run on any operating system and hardware. Now question is how it is platform independent? This is because of the magic of Byte Code which is OS indepedent. When java compiler compile any code then it generate the byte code not the machine native code(unlike C compiler).Now this byte code need a interpreter to execute on a machine.This interp
Exception – Handle or Declare Rule Java – Exceptions An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore, these exceptions are to be handled. Advantage of Exception Handling The core advantage of exception handling is to maintain the normal flow of the application . Exception normally disrupts the normal flow of the application that is why we use exception handling. Let’s take a scenario: statement 1 ; statement 2 ; statement 3 ; statement 4 ; statement 5 ; //exception occurs statement 6 ; statement 7 ; statement 8 ; statement 9 ; statement 10 ; Suppose there are 10 statements in your program and there occurs an exception at statement 5, rest of the code will not be executed i.e. statement 6 to 10 will not run. If we perform exception handling,