Which of the following statements prints a variable named total to the console, followed by a new line character?
| a. |
System.out.print(total); |
|
| b. |
System.out.println(total); |
|
| c. |
Console.out.println(total); |
|
| d. |
Console.out.print(total); |
Which of the following statements prints a variable named total to the console, followed by a...
Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...
Which of the following statements converts a String object named subtotalString to a double variable named subtotal? a. double subtotal = Double.parseDouble(subtotalString); b. double subtotal = Double.toString(subtotalString); c. double subtotal = (double) subtotalString; d. double subtotal = subtotalString.parseDouble;
Which of the following statements uses a Scanner variable named sc to return the next value the user enters at the consolse as a String object and store it in a variable named city? a. String city = sc.next(); b. String city = sc.nextString(); c. String city = sc.next().toString(); d. String city = sc.nextValue();
1) Which of the following is the name of a local variable in the
Strange class below?
public class Strange{
public static final int MAX = 5;
public static void unknown(){
int number = 0;
for (int i = MAX; i >= 1; i--)
number += i * i;
System.out.println(number);
}
public static void main(String[] a){
unknown();
}
}
a) Strange
b)
int
c)
MAX
d)
number
e)
main
2) Which of the following is NOT a method of the...
Challenge: C# Basics Description: Write a C# console application using .NET Core that utilizes constants, variables, data types, operators, expressions, statements, blocks, and control flow. Purpose: This application provides experience in working with basic language features of C#. It is important when working with a new language to understand how it handles its constants, variables, data types, operators, expressions, statements, blocks, and control flow. A good thing to always do with a new language is to build test applications where...
I need a java program that prints the following: 1* 2** 3*** 4**** 5***** 6****** 7******* 8******** 9********* This is what I have so far, but I cannot figure out how to fix it. public class HelloWorld{ public static void main(String []args){ System.out.println("Pattern Two"); for (int line=1; line<10; line++){ System.out.println(); for (int j=1; j System.out.print(line); for (int i=1; i System.out.print("*"); } } } } }
In this assignment, you will implement a class named KaraokeConsole which mimics the console of a karaoke system. This console allows the user to add a new song title to the playlist, play current song move back to previous song title, and move down to next song title. This console, which can hold a maximum of 10 songs, has five buttons: how each button works On/Off, Next, Back, Play, and Add. The table below shows Device Result of pressing a...
Assume the only console output method available is display(c), as shown below, which you include in your solution. This means you are not permitted to use System.out.print(), System.out.println(), nor System.out.printf() in your methods. public static void display (charc) { System.out.print (c); Implement the following methods in a program class, that has a main() method that simply tests each. Apply the concept of overloading, where best, and that the methods can call other new methods to reduce repeating the same code....
Question 39 (1 point) Which one of the following statements can be used to get the fifth character from a string str? char c - str.charAt(4): char c - str[5]: char c = str(4): char c - str.charAt(5): Question 40 (1 point) What does the following statement sequence print If the user input is 1234 public static void main(String args) Scanner in new Scanner (System.in); System.out.print("Enter a number: "); String strin.next( St 456; System.out.println(str) Compile-time error 123456 579 Run-time error
The return type for a function that only prints a menu to the console. Question options: a) bool b) double c) int d) string e) void f) char