Category Archives: Java Programs

How would you print a given currency value for Indian Locale (INR Currency)?

In this post we will talk and learn How would you print a given currency value for Indian Locale  (INR Currency) in java? NumberFormat class is designed specifically for this purpose. Currency symbol & Rounding Mode is automatically set based on the locale using NumberFormat. Lets see an example..

Output::  Amount = Rs.22.1215 You… Read More »

Which data type would you choose for storing currency values like Trading Price in Java?

In this post we will talk and learn  Which data type would you choose for storing currency values like Trading Price ? What is your opinion about Float, Double and BigDecimal data types ? Let’s see how double data type works for financial calculation

Sample output of above program: Total Amount = 20.19999999999996 The… Read More »

What are the important paradigms for Developing the Clean Object-Oriented Code?

In this blog post we will discuss about What are the important paradigms for Developing the Clean Object-Oriented Code? We should always keep in mind below key points when you write code in your application: We should use an Interface (or the Super Type) not the implementation. Classes Interacting each other should be loosely coupled among… Read More »

What will be the output of following java program?

In this post we will learn about one of very tricky java programming interview question where interviewer will give you code snippet and you will have to find the output of given code snippet. What will be the output of following java program?

 Answer: The code won’t compile because we can’t have an Object class… Read More »

Adding two numbers without using arithmetic operators

As you know to find sum of to two numbers we usually use arithmetic operator(+) but in this post we will write a java program to Adding two numbers without using arithmetic operators.

Sample output of above program:

You may also like: How to convert number to words in java How to swap… Read More »

What will happen if in a try block we throw an exception but in the finally block we return a int value ?

In this we post we will discuss about one of very important java interview question and question is that What will happen if in a try block we throw an exception but in the finally block we return a int value ?

Output of above program: The return Value : 10 You may also like… Read More »