Java How To Program (Early Objects)
Java How To Program (Early Objects)
10th Edition
ISBN: 9780133807943
Author: Deitel, Paul
Publisher: Pearson Education
bartleby

Concept explainers

bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 4, Problem 18.1E

Explanation of Solution

Given code:

//Check whether "x" is greater than "5"

if (x > 5)

    //Check whether "y" is greater than "5"

    if (y > 5)

        //Print the string

        System.out.println("x and y are > 5");

//Otherwise

else

    //Print the string

    System.out.println("x is <= 5");

Explanation about the given code:

  • In the given code, the body of “if” is a nested “if-else”.
  • The outer “if” checks whether “x” is greater than “5”.
  • If the condition is “true” then the inner “if” checks whether the “y” is greater than “5”.
  • If the condition is “true” then the string “x and y are >5” is printed. Otherwise the string “x is <=5” is printed even if the value of “x” is greater than “5”.
  • If the outer “if” condition is “false”, then nothing is executed because, the “else” block is associated with the immediately preceding “if”.
  • If the user wants the program to execute as it was originally intended, the given code is modified with the braces...

Blurred answer
Students have asked these similar questions
Need Java method please. Thank you.
Need Java method please. Thank you.
3. Write two nested loops to generate the following output. (Note: There is one space between each number, and any extra line shown is intentional.) 12 10 8 6 18 15 12 24 20 30 2 3 3 6 48 12 5 10 15 20 6 12 18 24 30

Chapter 4 Solutions

Java How To Program (Early Objects)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License