Question

Question 2 1 point possble (graded) Consider the following code segment. String a- a0 if (a-0) else if (a1) else if (a else( System.out.printin(a is 0 System.out.printin(a is 1! System.out.println(a is al) System.out.println(a is something else!) Which of the following statements about the code segment is true? It produced a is 0! as output It produced a is 1! as output It produced a is a! as output It produced a is something else! as output It results in an error because theoperation can not be used with Strings

0 0
Add a comment Improve this question Transcribed image text
Answer #1

2)   A
   29 30
   C
   2+3+4+5 = 14 times
   B
8)   B
9)   1 6
   D. 14

Add a comment
Know the answer?
Add Answer to:
Question 2 1 point possble (graded) Consider the following code segment. String a- a0 if (a-0")...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The following code segment demonstrates short circuit evaluation: if (0 == 1 && 2 + 2...

    The following code segment demonstrates short circuit evaluation: if (0 == 1 && 2 + 2 == 4){ System.out.println("A"); } else { System.out.println("B"); } Which of the following statement is TRUE to describe the above code segment? Select one: Since 0 == 1 is false, 2 + 2 == 4 will not be evaluated because Java declares the entire expression to be true. O Since 0 == 1 is false, 2 + 2 == 4 will not be evaluated because...

  • 1. Consider the following code segment. String str = "AP"; str += "CS " + 1...

    1. Consider the following code segment. String str = "AP"; str += "CS " + 1 + 2; System.out.println(str); What is printed as a result of executing the code segment? A: CS AP12 B: AP CS3 C: CSAP 12 D: APCS 12 E: APCS 3 2. Consider the following code segment. String dessert = "pie"; dessert += "straw" + dessert + "berry"; What is the value of dessert after the code segment has been executed? A: strawpieberry B: piestrawpieberry C:...

  • Question 33 Consider the following code segment. String letters - ("A", "B", "C", "D"), ("E", "P",...

    Question 33 Consider the following code segment. String letters - ("A", "B", "C", "D"), ("E", "P", "G", "1"), ("I", "J", "K", "L"}}; for (int col = 1; col < letters[0].length; col++) for (int row - 1; row < letters.length; row++) System.out.print(letterstrow][col] + " "); System.out.println(); What is printed as a result of executing this code segment? AET PJ DHL G J K L PJ GK

  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...

  • D Question9 Which of the following represents the output of the following code segment? abstract class...

    D Question9 Which of the following represents the output of the following code segment? abstract class Base Base0System.out.println("Base Constructor Called"); abstract void fun: class Derived extends Base Constructor Called"): fun) called"): ) class MainClass Derived0 System.out.println("Derived void fun [System.out.printin/"Derived public static void main(String args) Derived d = new Derived@; O Print "Derived Constructor Called then print Base Constructor Called O Print "Base Constructor Called then print Derived Constructor Called" O We must write @override above the fun) method in Derived...

  • Question 47 (1 point) What is the output generated by the code segment below, assuming that...

    Question 47 (1 point) What is the output generated by the code segment below, assuming that source is a Scanner object used to read the following text: Suzy sells seashells on the seashore. source.useDelimiter(" "); int count = 0; while (source.hasNext()) { char input = source.next().charAt(0); if (Character.isLetter (input)) count++; { } System.out.println(count); A/

  • Consider the following C++ code segment: for (int i = 0; i <n; ++i) { for...

    Consider the following C++ code segment: for (int i = 0; i <n; ++i) { for (int j = 0; j <m; ++j) if (i != j) cout << "0"; else cout << "1"; } } Which of the options below gives the correct output if the value of nis 2and the value of mis 3? 1. 100010 2. 011101 3. 100100 4. 010001

  • Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point...

    Question 1 True and False are Boolean keywords in Python True False Question 2 0.0/1.0 point (graded)       hot_plate = True if hot_plate:     print("Be careful, hot plate!") else:     print("The plate is ready.") The output of from running the above code is ___ "Be careful, hot plate!" "The plate is ready." "True" NameError Question 3 0.0/1.0 point (graded)       vehicle_type = "Truck" if vehicle_type.upper().startswith("P"):     print(vehicle_type, 'starts with "P"') else:     print(vehicle_type, 'does not start with "P"')     The...

  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {    super();    System.out.println(“B() called”);...

  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {   super();   System.out.println(“B() called”); } public...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT