A methods in java contains a block of code, or it is known as a piece of java code packed together called as methods. for a specific purpose we write a method and use that methods in different places in a class or from different classes. in java method follows a fixed type of declaration, […]

# Author: Interviewlogs

## Fibonacci sequence java

The Fibonacci Sequence is the series of numbers, where the next number is found by adding the two previous numbers. The first two numbers of the Fibonacci sequence is 0 followed by 1, and next are by adding previous two as follows.. 0, 1, 1, 2, 3, 5, 8, 13, 21, … 0+1)(1+1)(1+2)(2+3)(3+5)(5+8)(8+13) below program […]

## Java Program to Find the Count of Occurrences of Each Character in a String

Simple java program to find the character occurrence in the given string , where input is ” interviewlogs ” and expected output is {i=2, n=1, t=1, e=2, r=1, v=1, w=1, l=1, o=1, g=1, s=1} . the logic to find the occurrence is in below steps. convert the string into a character array create a LinkedHashMap […]

## substring java

There are two variants of finding a substring in java provided in String class first method which takes single argument substring(int beginIndex) Returns a new string that is a substring of this string.method will return part of characters from index beginIndex to end or the string The second method which takes two argument substring(int beginIndex, […]

## problem based on method overriding

a java example with one overridden method and one one overloaded method in child class , the overloaded method is called by the child object with parent reference,what will be the output of the program , this is one of the tricky interview questions asked in sequence of overloading/ overriding questions.

## prime numbers from 1 to 100

A prime number is a number which is not divisible by any other number except 1 and itself. the java program given below is to print prime numbers from 1 to 100 or can print prime numbers between 1 to n. the basic logic is to identify a number is prime or not is in […]

## prime number program in java

A prime number is a number greater than 1, and which is divisible only by itself and 1. although 1 is not a prime number because as per definition of prime number, number should be greater than one. so after reading the definition we can identify the prime numbers. like 2,3,5,7, 11 etc. this post […]