Is the answer 35, 35?

Is the answer 35, 35?

int a = 5; int b = 7; int num = 35; while (a < b) { System.out.println(?My age is ? + num); a = a + 1; }

View Answers

December 23, 2010 at 1:08 PM

Hello Friend,

class Check{
    public static void main(String[] args) 
    {
        int a = 5;
        int b = 7;
        int num = 35;
        while (a < b) { 
        System.out.println("?My age is ? "+ num);
        a = a + 1;
        }
    }
}

The above program outputs: My age is ? " 35 My age is ? " 35

As you have created a condition that a should be less than b.And you have specified a=5 and b=7.So firstly it takes the value of a 5 and check the condition and returns 35. Then it checks the incremented value i.e a+1, it is also less than 7 so it returns 35. Then again it checks but this time value will be 8 which is larger than b i.e. 7 so the loop ends here.

Thanks

Thanks









Related Tutorials/Questions & Answers:
Is the answer 35, 35?
answer it soon
Advertisements
answer
java.please answer this...
com.groupbyinc - parent version 35 Maven dependency. How to use parent version 35 in pom.xml?
ModuleNotFoundError: No module named 'answer'
ModuleNotFoundError: No module named 'answer'
ModuleNotFoundError: No module named 'answer'
Answer for SCJP Module-1 Question-13
pls answer the Trangle pattern
Urgent Answer Req
please answer me
Please give me the answer.
share your answer to this question
pls answer these question
Maven dependency for io.trino - trino-array version 359 is released. Learn to use trino-array version 359 in Maven based Java projects
Maven dependency for io.trino - trino-mysql version 359 is released. Learn to use trino-mysql version 359 in Maven based Java projects
Maven dependency for io.trino - trino-tpch version 359 is released. Learn to use trino-tpch version 359 in Maven based Java projects
Maven dependency for io.trino - trino-jdbc version 359 is released. Learn to use trino-jdbc version 359 in Maven based Java projects
Maven dependency for io.trino - trino-parser version 359 is released. Learn to use trino-parser version 359 in Maven based Java projects
Maven dependency for io.trino - trino-client version 359 is released. Learn to use trino-client version 359 in Maven based Java projects
Maven dependency for io.trino - trino-hive version 359 is released. Learn to use trino-hive version 359 in Maven based Java projects
Maven dependency for io.trino - trino-matching version 359 is released. Learn to use trino-matching version 359 in Maven based Java projects
Maven dependency for io.trino - trino-memory version 359 is released. Learn to use trino-memory version 359 in Maven based Java projects
Maven dependency for io.trino - trino-hive-hadoop2 version 359 is released. Learn to use trino-hive-hadoop2 version 359 in Maven based Java projects
Maven dependency for io.trino - trino-blackhole version 359 is released. Learn to use trino-blackhole version 359 in Maven based Java projects
Maven dependency for io.trino - trino-jmx version 359 is released. Learn to use trino-jmx version 359 in Maven based Java projects
Maven dependency for io.trino - trino-mongodb version 359 is released. Learn to use trino-mongodb version 359 in Maven based Java projects
Maven dependency for io.trino - trino-array version 358 is released. Learn to use trino-array version 358 in Maven based Java projects
Maven dependency for io.trino - trino-tpch version 358 is released. Learn to use trino-tpch version 358 in Maven based Java projects
Maven dependency for io.trino - trino-jdbc version 358 is released. Learn to use trino-jdbc version 358 in Maven based Java projects
Maven dependency for io.trino - trino-parser version 358 is released. Learn to use trino-parser version 358 in Maven based Java projects
Maven dependency for io.trino - trino-hive version 358 is released. Learn to use trino-hive version 358 in Maven based Java projects
Maven dependency for io.trino - trino-matching version 358 is released. Learn to use trino-matching version 358 in Maven based Java projects
Maven dependency for io.trino - trino-hive-hadoop2 version 358 is released. Learn to use trino-hive-hadoop2 version 358 in Maven based Java projects
Maven dependency for io.trino - trino-blackhole version 358 is released. Learn to use trino-blackhole version 358 in Maven based Java projects
Maven dependency for io.trino - trino-jmx version 358 is released. Learn to use trino-jmx version 358 in Maven based Java projects
Maven dependency for io.trino - trino-mongodb version 358 is released. Learn to use trino-mongodb version 358 in Maven based Java projects
Maven dependency for io.trino - trino-mysql version 358 is released. Learn to use trino-mysql version 358 in Maven based Java projects
Maven dependency for io.trino - trino-client version 358 is released. Learn to use trino-client version 358 in Maven based Java projects
Maven dependency for io.trino - trino-memory version 358 is released. Learn to use trino-memory version 358 in Maven based Java projects
Maven dependency for io.trino - trino-mysql version 356 is released. Learn to use trino-mysql version 356 in Maven based Java projects
Maven dependency for io.trino - trino-tpch version 356 is released. Learn to use trino-tpch version 356 in Maven based Java projects
Maven dependency for io.trino - trino-client version 356 is released. Learn to use trino-client version 356 in Maven based Java projects
Maven dependency for io.trino - trino-memory version 356 is released. Learn to use trino-memory version 356 in Maven based Java projects
Maven dependency for io.trino - trino-array version 356 is released. Learn to use trino-array version 356 in Maven based Java projects
Maven dependency for io.trino - trino-jdbc version 356 is released. Learn to use trino-jdbc version 356 in Maven based Java projects
Maven dependency for io.trino - trino-parser version 356 is released. Learn to use trino-parser version 356 in Maven based Java projects
Maven dependency for io.trino - trino-hive version 356 is released. Learn to use trino-hive version 356 in Maven based Java projects
Maven dependency for io.trino - trino-matching version 356 is released. Learn to use trino-matching version 356 in Maven based Java projects

Ads