OR--------> ONLY ONE STATEMENT NEEDS TO BE TRUE package com.cnc ; public class Main { public static void main ( String [] args) { if (( topScore > 90 ) || ( secondTopScore )<= 90 ){ System . out .println( "Either or both of the condition are true" ); } } }
In computer programming, an array is a collection of similar types of data. For example, if we want to store the names of 100 people then we can create an array of the string type that can store 100 names. String[] array = new String[ 100 ]; The number of values in the Java array is fixed. That is, the above array can not store more than 100 elements. How to declare an array in Java? In Java, here is how we can declare an array. dataType[] arrayName; dataType - it can be primitive data types like int , char , double , byte , etc. or Java objects arrayName - it is an identifier For example, double [] data; Here, data is an array that can hold values of type double . But, how many elements can array this hold? Good question! To define the number of elements that an array can hold, we have to allocate memory for the array in Java. For example, // declare an array double [] data; // allocate memory data = new ...
Consider an address: let's say it has a number and street name only Java code for this could be : String number = "52" ; String street = "The Leeway" ; System . out . println ( number + " " + street ); Ok so we see all the variables and the means to which the street was printed to us, if we encapsulate though we can do this: public class Address { private String streetName ; private String number ; public Address ( String streetNametName , String number ){ this . streetName = streetNametName ; this . number = number ; } public String getStreetName () { return streetName ; } public void setStreetName ( String streetName ) { this . streetName = streetName ; } public String getNumber () { return number ; } public void setNumber ( String number ) { this . number = number ; } public Stri...