Java enables us to return objects from the methods as well. Returning and passing objects need to consider the parent child relationship among the classes. This relationship holds importance because, as a matter of fact, Object of parent class can hold the address of object of child class.
Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts
Java program to check whether a number is palindrome or not
Checking whether a number is palindrome or not, is one of the earlist classic problem in programming. A number is said to be palindrome if on reversing the number, we get the same number. For example, consider the number 121, on reversing we get 121. So, it is a palindrome number. Java program to check whether a number is palindrome or not is given.
Fibonacci series program in Java
Fibonacci series is one the most series es in the world. In a Fibonacci series, each term is the sum of last two terms. For the first two terms, 1st is taken as 0 and second is taken as 1. Fibonacci series has attracted a lot of attention and research. So. let us devote a JAVA program to print the Fibonacci series.
Java program to reverse a number
Java program to reverse a number is one of the simplest programming problems. The JAVA program that reverses a number is given.
How to use Objects as Parameter
The first thing that anyone needs to know is the difference between argument and parameters. Arguments are the variables that are passed to the functions and parameters are the variables that receive the value of the arguments. Java rich Object Oriented Features allow us to use Objects as the parameter.
Recursive Factorial Program in Java
Recursion is the process in which a function calls itself. Generally, iterative programs are slower than corresponding iterative versions of the same program but recursion has found its use due to the fact that sometimes, it is easier to develop recursive version of the program than to develop a iterative version of the same program. The general condition for the recursive program is to have a condition that should fail at some point in the program and at that point, the program needs to traverse back to generate the final answer. Without this condition, your program may fall into an infinite loop, so, the program will never stop unless the stack of method calls is overflowed.
Factorial Program in Java
In mathematics, the factorial of the number is defined as
n! = n*(n-1)*(n-2)*(n-3)*(n-4)*...1
n! = n*(n-1)*(n-2)*(n-3)*(n-4)*...1
Method Overloading Demystified
Method Overloading is one of the best features of the Object Oriented Language. With Method Overloading, Java implements Polymorphism.
Garbage Collector Program in JAVA
Java language dynamically allocates the memory to the objects of the classes being used in the program. Unlike C++ where a destructor is needed to free the memory, JAVA employs Garbage Collector Mechanism to reclaim the allocated memory. When no referance to the object exists in the memory, it becomes eligible to be collected by Garbage Collector.
The finalize method provided by java sees to it that this method is executed just before the memory allocated to the object is being reclaimed. There is no gurantee that a finalize method would be executed. My aim was to observe the functioning of the garbage collector. So, I created a program. And here it is.
Subscribe to:
Posts (Atom)