GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

Author Archives: Anonymous

Convert the following switch statement to an if-else block s…

Convert the following switch statement to an if-else block so the output is the same for all cases. Assume the switch variable is already declared and initialized. Note that some lines may need to be blank, if that is the case and there are multiple lines in the block, the blank line MUST BE THE LAST LINE in the block.  For example (follow this format):   if (a == 10) { sum += 10; //LEAVE BLANK }   Instead of (do NOT do this):   if (a == 10) { //LEAVE BLANK sum += 10; }  Some lines may be used once, never, or multiple times.  switch (country) { case ‘V’: System.out.println(“….”); case ‘P’: System.out.println(“////”); break; default: System.out.println(“****”); case ‘I’: System.out.println(“!!!!”); }     if (1._______________) {  2._______________________  3._______________________ } else if (4._______________) {  System.out.println(“////”); } else if (5.________________) {  System.out.println(“!!!!”); } else {  6._______________________  7._______________________     } 

Read Details

You have a file Bank.java and you have a driver class named…

You have a file Bank.java and you have a driver class named Driver.java. Fill in the correct visibility modifiers so that the comments in the main method are upheld.  public class Driver {     public static void main(String[] args) {         Bank t = new Bank();        // each of the lines below is run independently        System.out.println(t.totalMoney); // compiles and run        System.out.println(t.getTotalMoney()); // compiles and runs System.out.println(t.id);    // compile error     } }  —— in a separate file in a different package/directory ———  public class Bank {        1   int id;       2   double totalMoney;       3   double getTotalMoney() {        return totalMoney;     }     /** no-argument constructor implemented **/ }    1  :[vis1]   2  :[vis2]   3  :[vis3]

Read Details

Convert the following switch statement to an if-else block s…

Convert the following switch statement to an if-else block so the output is the same for all cases. Assume the switch variable is already declared and initialized. Note that some lines may need to be blank, if that is the case and there are multiple lines in the block, the blank line MUST BE THE LAST LINE in the block.  For example (follow this format):   if (a == 10) { sum += 10; //LEAVE BLANK }   Instead of (do NOT do this):   if (a == 10) { //LEAVE BLANK sum += 10; }  Some lines may be used once, never, or multiple times.  switch (food) { case 1: System.out.println(“arepas – delicious”); case 2: System.out.println(“falafel – mouthwatering”); break; default: System.out.println(“nay”); case 3: System.out.println(“ceviche – scrumptious”); }     if (1._______________) {  2._______________________  3._______________________ } else if (4._______________) {  System.out.println(“falafel – mouthwatering”); } else if (5.________________) {  System.out.println(“ceviche – scrumptious”); } else {  6._______________________  7._______________________     } 

Read Details

Given the if/else block, choose the corresponding ternary ex…

Given the if/else block, choose the corresponding ternary expression.   int a = 9; int b = 3; int result;if (a == b) { result = a / b; } else { result = a – b; } 

Read Details

 \\                =o)  (o>               /\\ _(()__Java Bas…

 \\                =o)  (o>               /\\ _(()__Java Basics__\_V_ //                 \\                      \\

Read Details

Write 2-3 lines of code to:  Declare a String variable and…

Write 2-3 lines of code to:  Declare a String variable and save your favorite color in it. Print the value of the variable to the console with a newline character after it.  Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.

Read Details

Write 2-3 lines of code to:  Declare a String variable and…

Write 2-3 lines of code to:  Declare a String variable and save your name in it. Print the value of the variable to the console with a newline character after it.  Make sure to select the ‘Preformatted’ style from the dropdown so your code is formatted clearly. DO NOT USE THE TAB KEY WHEN WRITING CODE AS YOU MAY ACCIDENTALLY SUBMIT YOUR EXAM. USE THE SPACE BAR INSTEAD.

Read Details

 \\         tweet =o)  (o> tweet        /\\ _(()____________…

 \\         tweet =o)  (o> tweet        /\\ _(()_______________\_V_ //                 \\      (goodbye!)    \\

Read Details

Given the following code, what is the value of b?   String s…

Given the following code, what is the value of b?   String str1 = “Tomatoes”; String str2 = str1; str2.replace(‘m’,’?’); boolean b = (str1.equals(str2)); 

Read Details

For the given code below, which lines are valid (will compil…

For the given code below, which lines are valid (will compile and run)? Assume each line is run independently.   public class Foo {     private static int number;     private int jar;     public static double fuzz() {        return 0.0;     }     public int flop() {        return 0;     }     public static void main(String[] args) {         Foo obj = new Foo();        1 obj.fuzz();        2 obj.flop();        3 Foo.fuzz();        4 Foo.flop();                                    5 System.out.println(obj.number);        6 System.out.println(obj.jar);        7 System.out.println(Foo.number);          8 System.out.println(Foo.jar);      } }    1  : [1]   2  : [2]   3  : [3]   4  : [4]   5  : [5]   6  : [6]   7  : [7]   8  : [8]

Read Details

Posts pagination

Newer posts 1 … 72,578 72,579 72,580 72,581 72,582 … 81,929 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top