Duck Number Program in Java with Examples

In this short tutorial I will be sharing what is Duck number, examples of Duck number, algorithm and program to check whether a given number is Duck number or not.

Read Also : Java Program to Check Neon Number 

What is Duck Number 

A number is called as Duck number if zeroes are present in it but there should be no zero present at the beginning of the number. 

Examples :

Number to check : 3100  
Number contains zero : Yes 
Zero at the beginning : No // 3100 is a Duck number
 
Number to check : 7430689  
Number contains zero : Yes 
Zero at the beginning : No // 7430689 is a Duck number

Below are examples of numbers which are NOT Duck numbers

Number to check : 07010  
Number contains zero : Yes 
Zero at the beginning : Yes // 07010 is NOT a Duck number
 
Number to check : 003189  
Number contains zero : Yes  
Zero at the beginning : Yes // 003189 is NOT a Duck number

List of Duck numbers from 1 to 100 are : 
10, 20, 30, 40, 50, 60, 70, 80, 90, 100

Java Program for Duck Number

Neon Number Program in Java with Examples

In this short tutorial I will be sharing what is Neon number, examples of Neon number, algorithm and program to check whether a given number is Neon number or not.

Read Also : Java Program to Check Magic Number

What is Neon Number

A number is called as  Neon number if sum of digits of the square of the number is equal to the  number.

Examples :

Number to check :  
Square of a given number : 9 * 9 = 81
Sum of digits of square number : 8 + 1 = 9 // 9 is a Neon number
 
Number to check :  
Square of a given number : 1 * 1 = 1
Sum of digits of square number : 1 // 1 is a Neon number

Below are examples of numbers which are NOT Neon numbers

Number to check : 13  
Square of a given number : 13 * 13 = 169
Sum of digits of square number : 1 + 6 + 9 = 16 // 13 is NOT a Neon number
 
Number to check :  
Square of a given number : 8 * 8 = 64
Sum of digits of square number : 6 + 4 = 10 // 8 is NOT a Neon number

List of Neon numbers from 0 to 100 are : 
0, 1, 9

Java Program for Neon Number

Magic Number Program in Java with Examples

In this tutorial I will be sharing what is Magic number, examples of Magic number, algorithm and java program to check whether a given number is Magic number or not.

Read Also :  Java Program to Check Bouncy Number  

What is Magic Number

A Magic number is a number whose sum of its digits are calculated till a single digit is obtained by recursively adding the sum of its digits. If single digit obtained is 1, then the number is magic number, otherwise not.
Examples :

Number to check : 19 
1 + 9 = 10        // 10 is not a single digit number, continue adding digits   
1 + 0 = 1         // 19 is a Magic number
 
Number to check : 1891 
1 + 8 + 9 + 1 = 19 // 19 is not a single digit number, continue adding digits   
1 + 9 = 10         // 10 is not a single digit number, continue adding digits 
1 + 0 = 1          // 1891 is a Magic number 

Below are examples of numbers which are NOT Magic numbers

Number to check : 29 
2 + 9 = 11        // 11 is not a single digit number, continue adding digits   
1 + 1 = 2         // 29 is NOT a Magic number
 
Number to check : 2888 
2 + 8 + 8 + 8 = 26// 26 is not a single digit number, continue adding digits   
2 + 6 = 8         // 2888 is NOT a Magic number

Java Program for Magic Number

RESTful Web Services : Simple Tutorial for Beginners

If you are familiar with modern web development then you will have encounter the terms like REST and API. If you have worked with APIs or heard of these terms but do not have complete understanding of how to build your own API or how they communicate and work, this tutorial RESTful web services - simple tutorial for beginners is for you.

In this tutorial, I will be sharing what are REST and RESTful APIs, overview of REST principles, understanding the terms Request and Response, REST API Endpoints and at last conclusion.

Read Also : Web Services Interview Questions

Understanding REST and RESTful APIs

REST is an abstract concept. It is not a framework, programming language or kind of software.

REST is also known as Representational State Transfer. It conveys an architectural style for web-services.

REST provides a set of standards or constraints for sharing data between different systems.
RESTful systems are those systems which implement REST.

First we will understand what is an API before understanding the term RESTful API.

An API (Application Programming Interface) is an interface that permit communication between software programs. A RESTful API is an API that follows the standards and constraints of REST.
In a Web API, request is passed to the server through a URL endpoint(see below) and after processing the request, a response is sent. Response is often data in a format like JSON.

Top 50 Java Collections Interview Questions and Answers

We have already shared the most frequently asked java interview questions for experience candidates. Also shared the tricky coding interview questions in our previous posts. Today , we will learn about the top 50 java collections interview questions and answers. We will divide this post into three categories (Updated for 2019) :

Beginner level (0-1 year experience (Freshers)) ,

Intermediate level (1-3 years experienced Java Developers)

Advanced level(3+ Experienced) java collections interview questions and answers

Note : Please prepare all the below questions . Interviewer may choose to ask any question.

Beginner Level (0-1 yr): Java Collections Interview Questions  and Answers


Q1  What is Collection ? What is a Collections Framework ? What are the benefits of Java Collections Framework ?

Collection : A collection (also called as container) is an object  that groups multiple elements into a single unit.

Collections Framework : Collections framework provides unified architecture for manipulating and representing collections.

Benefits of Collections Framework :

1. Improves program quality and speed
2. Increases the chances of reusability of software
3. Decreases programming effort.

Q2 What is the root interface in collection hierarchy ? 

Root interface in collection hierarchy is Collection interface . Few interviewer may argue that