It is aslo known as repetitive structure. Loop structure is used to run the block of codes until the condition is satisfied. While in execution, the if the condition is true then it is executed if the condition is false then the loop is terminated and follows the next statement of loop. Loop structure continue to execute until the condition is satisfied and it is very useful in many areas because of this feature. In java programming language, there are three options to use repetitive structure. 1) ' while ' statement 2)' do-while' statement 3)' for ' statement 1)'while' statement In while statement, certain code of block runs which is inside the while loop structure until the condition becomes false. After being the condition false, the loop will terminate itself. Syntax:- while(<condition expression>) { //program code } 2)'do-while ' statement It is also a type of statement. In this type of structure, while exp...
To understand the Class and Object in java, first you simply you imagine the real world. Suppose you have a house. In house we stay, before we stay we build a house. Before we build house, we design it. We make a sketch or blue print of that house. In that sketch we determine structure of house in form of architectural drawing. We all know that we can't stay in that architectural drawing. We have to built a house to stay in it. Here, class is like a sketch and the object is house. \ A class is like the architectural drawing of a house from which the house object is built. Just as you can’t stay in an architectural drawing of a house, you cannot ‘stay’ in a class. Just as someone has to build a house from its architectural drawing before you can actually stay in it, you must build an object of a class before you can get a program to perform the tasks defined in the class. In a housing estate, there are many houses built from the same architectural design. ...
Logical operators are widely used in decision making in JAVA. The Operators are used to check the given condition or expression whether they are true or false. Mostly logical operators are used to check condition if there are two or more expression and whether the expressions(two or more expressions) are returning true or not. There are three logical operator i.e. AND Operator (&&), OR Operator (||) and NOT Operator (!). Lets see below example to explore it in more convenient way. Let's suppose we are making console application based voting system. The criteria are defined below. 1)Must be citizen of some regulatory body, lets assume Nepal. At first he or she must have proof that he or she crossed 16 and has citizenship card. Then only the persoin is known as citizen. 1) Must have crossed age 18. (Age defined he or she is eligible for vote or not). 2) Must have Voting Card. If all the condition is satisfied then he or she is elig...
Comments
Post a Comment