Answer:
ayo fam
Explanation:
I dont think this is supposed to be here lol
Answer:
public class Digits
{
public static boolean allDigitsOdd(int num)
{
boolean flag=true;
int rem;
while(num>0)
{
rem=num%10;
num=num/10;
if(rem%2==0) // if a even digit found immediately breaks out of loop
{
flag=false;
break;
}
}
return flag; //returns result
}
public static void main(String args[])
{
System.out.println(allDigitsOdd(1375)); //returns true as all are odd digits
}
}
OUTPUT :
true
Explanation:
Above program has 2 static methods inside a class Digits. Logic behind above function is that a number is divided by 10 until it is less than 0. Each time its remainder by 0 is checked if even immediately breaks out of the loop.
Answer:
The code is given in the explanation section
Explanation:
//Class Airconditioner
public class AirConditioner {
private boolean turnOnOff;
//The Constructor
public AirConditioner(boolean turnOnOff) {
this.turnOnOff = turnOnOff;
}
//method turn_on
public void turn_on(){
this.turnOnOff = true;
}
//method turn_off
public void turn_off( ){
this.turnOnOff = false;
}
}
// A new class to test the airconditional class
class AircondionTest{
public static void main(String[] args) {
//Creating an object of the Aircondional class
AirConditioner office_a_c = new AirConditioner(false);
//Using the reference varible to call method turn_on
office_a_c.turn_on();
}
}
The answer is D because a toutourial can explain each and everey process