answersLogoWhite

0


Best Answer

The If else if construct is usually used when a series of conditions need to be validated or checked one by one.

Say for example you are writing a program to decide on projected weight of a person then you may need to have an if - else if block.

If height > 4 feet then

weight should be atleast 40 kgs

else if height > 5 feet then

weight should be atleast 50 kgs

else if height > 6 feet then

weight should be atleast 60 kgs

and so on...

Example code.

This method takes the height in inches as input and returns weight in kilograms as output.

public int getMinWeight(int height){

if(height > 4) {

return 40;

} else if(height > 5){

return 50;

} else if (height > 6){

return 60;

} else {

return 70;

}

}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Explain with an example the if-else-if construct in java language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

With illustrative example explain how Operating System Programming Language Hardware support the Computer Graphics?

With illustrative example explain how Operating System Programming Language Hardware support the Computer Graphics?


Explain pointer to function with example c language?

It isn't a question, sorry.


Explain with an example that the evaluation of language is social rather than linguistic?

An example of how the evaluation of language is social rather than linguistic is the use of slang. Slang terms may be seen as improper or unintelligent from a linguistic standpoint, but within certain social groups or communities, they can be highly valued and used as a way to create or signal belonging. This shows that the evaluation of language is influenced by social factors and context rather than purely linguistic criteria.


What does construct mean in math?

it means make something for example: construct a triangle then you would make a triangle.


What is a example of adaptations?

Spiders are an example of adaptation. They construct webs to catch prey.


What is user define datatype and explain it?

Any datatype which the user creates in code, that isn't native to the language. A linked list can be an example of this


What is string variables?

A string variable is a programming language construct that holds text. For example, the text "The sky is blue" could be stored to a string variable, then later in the program, that text could be displayed.


Is vbnet a SOA programming language or Object Oriented Programming Language?

Visual Basic is an Object oriented programing language, like C++. A good example of an SOA program language is C#. can you explain with reasons........? i agree with you .... I want to confirm the reason why it is so ...


Is race a biological construct?

A biological race is the race you were born as for example even though a Thesauris is a dinosour its still an Anphibian.


What is repeat loop?

Most programming languages have some loop construct, that make it possible to repeat commands several times. The available commands vary, depending on the language; as an example, Java has the "for", "while", and "do...while" keywords.


What do you men by precipitation explain by giving an example?

what do u mean by precipitation? explain by giving an example


What are conditional connectives. Explain with an example?

What are conditional connectives? Explain use of conditional connectives with an example