SHORT ANSWER .Please answer the following questions. 11. What is produced when y
ID: 3674346 • Letter: S
Question
SHORT ANSWER .Please answer the following questions.
11. What is produced when you run the following application?
using System;
using System.Console;
namespace ExerciseI {
class Problem2 {
static void Main() {
Console.Write("Go ");
Console.Write("Forth ");
Console.WriteLine("and DO");
Console.Write("Awesome ");
Console.Write("Stuff!");
}
}
}
12. What must be changed in the segment of code in the previous question to cause all of the output to be displayed on one line?
***************
13. Explain how a variable differs from a constant. ( Briefly a short answer )
*******************
14. The following program has several syntax errors as well as style inconsistencies.
Correct the syntax errors and identify the style violations.
public class Chair {
private string type;
private double weight;
private double cost;
private Chair() {
}
private Chair(weight, type, cost) {
}
public string ChairType {
get
{
return type;
}
set {
ChairType = value;
}
}
public override ToString()
{
return "Type of Chair: " + ChairType;
}
}
}
Explanation / Answer
11. What is produced when you run the following application?
output:
Go Forth and DO
Awesome Stuff!
12. What must be changed in the segment of code in the previous question to cause all of the output to be displayed on one line?
Solution: Modify the third line to contain Console.write("DO ") (instead of Console.writeLine)
13. Explain how a variable differs from a constant. ( Briefly a short answer )
Value to variable can be assigned more than once.
Value to Constant can be assigned only Once
14. Corrected solution
C# Pad New Window Help
C# Interactive Shellclose
(8,21): error
CS1001
: Identifier expected(19,17): error
CS1520
: Method must have a return type(24,1): error
CS7017
: Member definition, statement, or end-of-file expected
public class Chair
{
private string type;
private double weight;
private double cost;
private Chair() {
}
private Chair(double weight, string type,double cost) {
}
public string ChairType {
get
{
return type;
}
set {
ChairType = value;
}
}
public string toString()
{
return "Type of Chair: " + ChairType;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.