What will be the expected output after the following statements are executed? char custType = ‘c’; switch (custType) { case ‘A’: System.out.println(“The customer type is A”); break; case ‘B’: case ‘b’: System.out.println(“The customer type is B”); case ‘C’: System.out.println(“The customer type is C”); default: System.out.println(“The customer type is D”); }
Category: Uncategorized
Write a Java program that determines whether num is an even…
Write a Java program that determines whether num is an even or an odd number (divisible by 2). public static void main(String[] args){ Scanner keyboard = new Scanner(System.in); int num= 2025; if(num ){
What will be the output of this ternary operation? int x =…
What will be the output of this ternary operation? int x = 10, y = 5;String message = x > y ? “panther” : “dolphin”);System.out.println(message);
Rewrite this if-else statement using a ternary operator (one…
Rewrite this if-else statement using a ternary operator (one line of code only): if (price> 30) { discount = 0.3; } else { discount = 0.1; }
Explain the difference between primitive data types and refe…
Explain the difference between primitive data types and reference data types in Java
Find the error in the following code and discuss how to fix…
Find the error in the following code and discuss how to fix it. public class Test{public static void main(String[] args){ double x = 6.50; //we created a double variable int y; /*In the next line, we convert the double value to an integer value */ y = (double) x; } }
What is the difference between if-else and switch statements…
What is the difference between if-else and switch statements?
Write the expected output for the following code. String m…
Write the expected output for the following code. String msg = “I am enjoying this class.”; String msg1 = msg.toUpperCase(); String msg2 = msg.toLowerCase(); char ltr = msg.charAt(6); int strSize = msg.length(); System.out.println(msg); System.out.println(msg1); System.out.println(msg2); System.out.println(“Character at index 6 = ” + ltr); System.out.println(“msg has ” + strSize + “characters.”);
What will be the expected output after the following stateme…
What will be the expected output after the following statements are executed? char custType = ‘b’; switch (custType) { case ‘A’: System.out.println(“The customer type is A”); break; case ‘B’: case ‘b’: System.out.println(“The customer type is B”); case ‘C’: System.out.println(“The customer type is C”); default: System.out.println(“The customer type is D”); }
The Joiner 4GM book discusses a situation involving an auto…
The Joiner 4GM book discusses a situation involving an auto manufacturer and its two suppliers of transmissions. The transmissions from both suppliers consistently met specifications with no defectives. Nevertheless, the transmissions from Supplier A experienced more customer complaints and warranty service work, while the transmissions made by Supplier B performed well and rarely experienced warranty service work. Briefly explain the reason for the difference. Why did the transmissions from Supplier A and Supplier B perform differently even though they all met specifications?