Posts

Showing posts with the label Java Programming

Java features which makes the java most popular language..

Image
The java is a most popular programming language platform present in the world today. More than 30 Millions devices which run on java technology. Following are the most important properties of java which have made it no #1 choice for programmer around the world. 1) P latform Independent:-   Before we say and can understand meaning of the word platform, In programming the word platform means the environment In which a programs runs in simple words it is the combination of operating system and central processing unit. So window 10+ core i5 is one platform while Linux + core i7 is another platform. Now being platform independent means that a programmer which is compiled on window platform can directly executed on Linux platform without re-writing or re-compiling and java has speech up using it’s important component called 1. Bytecode 2. JVM. Whenever we compiled a java program the compiler never generates machine code rather the java compiler converts our program fro...

Exception Handling in java

The word exception in world in java means run time error and the word exception handling means the way our program behaves whenever the run time error occurs. But we can understand the importance of exception handling we must first understand how the java behaves by default when a exception occurs.      When a exception occur in java the jvm takes two action by default.  1) It immediately terminates our program as soon as an exception occur.       2) It displays a technical error message related to the exception on our output screen.          Both the above behavior are very much non-user friendly because        1)   Termination a program will not allow further code to execute even if that code has no relation with exception that has occurs.    2)   If the error message will be technical the user will not be able to understand the problem and might repeat wrong ...

What is the interface in java?

An interface in java , like an abstract class can be used to achieve run time polymorphism (dynamic method dispatch). Following are important point we must remember with respect to an interface:-     1)  Just like a class an interface also can contain data but all the data members declared is an interface are by default public static and final.     2)  Just like a class an interface also can contains method but every method declared as an public and abstract.      3)  Just like a class inherits another class it can also inherit an interface but the keyword use in inheritance for interface is implements.     4)  Just like an abstract class we can create reference of an interface but we can never create an object. However we can creates object of child class of an interface and assign it to the reference of the interface and using that reference we can call those method of the child class whic...

What is static initializer block in java ?

Before we learn about the static initializer block in java we must familiar with basic programming language like C/C++. To know the power of java programming language, I would like to give you a problem, try to make a solution for it. The problem is that to make a program in which make a class whose name is Account which has four data members 1)AccountId  (Should be an integer) 2)Account_holder_name (Should be a char array or String) 3)bank_balance(Should be an integer) 4)rate_of_interest (It should be an integer and also it will be same for all the account holders) And then write a program to display the AccountId and name of the account holder and also display his bank balance and rate of interest provided by a bank but the challenge is that to make a program in such a way that the static data member (rate_of_interest) initialized only once. If we create a constructor in our class then it will be called until the different object is created. It can be solved but we cannot s...