Help, Level 11 GenerlizationB question 2


Question 2:
Use a Boolean expression that will print out the code in the else block of the if/else statement. :sweat:

if(2015 < 2016) {

		System.out.println("Stuck in the past...");

	} else {

		System.out.println("Upgraded to the future!");


I dont understand the question and dont know how to solve out.... :confounded:


You ought to make your condition

2015>2016 // this is false since 2015 is actually smaller than 2016, hence the program will move into the else block

The way the if/else statement works is that You are checking if some condition(act or effect etc) is true, if it is then you want to do something otherwise if it is not true do something different. For example

public class PutOnMyRainCoat{
	public static void main(String[] args) {

		boolean it_will_rain = true;

		if (it_will_rain) {

			//since it_will_rain is true
			//the program will move into this block and execute
			//Whatever commands are in here
			//remember after all commands are executed in this block
			// the program will move outside(never into the else block)
			//and do whatever is there
			System.out.println("I am gonna put on my raincoat");

		}//end if block


			//if the value of it_will_rain was false
			//then the program will never move into the if block
			//but into the else block here
			//and execute all commands in here
			System.out.println("I dont need any raincoat");

		}//end else block

		//some commands carried out here too


Hi Rydan

Please post the entire code as it is supposed to be.

I am so Looooooost


public class GeneralizationsB {
public static void main(String[] args) {

// ( 3 >= 3 && !(true || true) );
boolean tricky = false;

if(2015 > 2016) {

	System.out.println("Stuck in the past...");

}else {

	System.out.println("Upgraded to the future!");


int subwayTrain = 5;

switch (subwayTrain){

	case 1 : System.out.println("This is a South Ferry bound train!");
	case 5 : System.out.println("This is a Brooklyn bound train!");
	case 7 : System.out.println("This is a Queens bound train!");
		System.out.println("I'm not sure where that train goes...");




This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.