ICS-114 Midterm Study
36 Questions
2 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which statement about identifiers in C# is correct?

  • An identifier must begin with a number.
  • Identifiers can contain spaces between words.
  • The underscore character is the only acceptable special character in identifiers. (correct)
  • Identifiers can include special characters such as $ and #.
  • What is the maximum number of characters you can store in a computer with 40 gigabytes of hard disk space?

  • 400 million characters
  • 40 billion characters (correct)
  • 40 million characters
  • 400 billion characters
  • Which of the following is a valid method of initializing a double type variable to zero?

  • double amountDue = 0; (correct)
  • double amountDue = 0f;
  • double amountDue = '0';
  • double amountDue = 0.0m;
  • What case naming convention do identifiers like LeaveMap and ActionHero follow?

    <p>Pascal case</p> Signup and view all the answers

    Which of the following statements about C# data types is true?

    <p>Every data type has an associated class.</p> Signup and view all the answers

    What character can be used to represent a value type that holds '0', '1', '2', etc.?

    <p>char</p> Signup and view all the answers

    Which of the following accurately represents the characters you can use at the beginning of an identifier in C#?

    <p>Any alphabetical character or underscore</p> Signup and view all the answers

    Which mechanical computing device was created by Charles Babbage?

    <p>The Analytical Engine</p> Signup and view all the answers

    What technology did the first general-purpose electronic computer notably use?

    <p>Vacuum tubes</p> Signup and view all the answers

    What is a notable feature of the Analytical Engine?

    <p>Considered the earliest prototype for a general-purpose computer</p> Signup and view all the answers

    In software development, what should be ensured during the first phase?

    <p>Understanding the problem definition</p> Signup and view all the answers

    What term describes a clear, step-by-step process for solving a problem?

    <p>Algorithm</p> Signup and view all the answers

    What is the term used for the rules that must be followed in a programming language like C#?

    <p>Syntax</p> Signup and view all the answers

    Which language is the result of the first step of .NET program compilation?

    <p>Microsoft Intermediate Language or MSIL</p> Signup and view all the answers

    What does the namespace in a C# program primarily achieve?

    <p>Groups functionally related types under a single name</p> Signup and view all the answers

    Which statement correctly describes the function of accessors in C#?

    <p>Accessors are used to access the value of an object.</p> Signup and view all the answers

    What does the keyword 'override' signify in a method definition?

    <p>It provides a new implementation for an inherited method.</p> Signup and view all the answers

    Which of the following is an incorrect way to invoke the CalculateAvg() method in a class?

    <p>answer = camStudent.CalculateAvg(53.2, 83.5, 94.6);</p> Signup and view all the answers

    What can be inferred if the statement plush.PricePerSqYard = 40.99; follows proper naming conventions?

    <p>All components in the statement follow proper naming conventions.</p> Signup and view all the answers

    Which statement is true regarding instance methods?

    <p>They can access private data members directly.</p> Signup and view all the answers

    Why would the following C# statement produce a syntax error? float totalAmount = 23.57;

    <p>It is missing the type specifier (f or F).</p> Signup and view all the answers

    What is the equivalent decimal value for 3.42e-4?

    <p>0.000342</p> Signup and view all the answers

    Which of the following is true about the C# bool data type?

    <p>It can take on values of true/false.</p> Signup and view all the answers

    What is the output of the following C# statement: Console.WriteLine(payment++); if int payment = 50;?

    <p>50</p> Signup and view all the answers

    What will the output be when you evaluate the expression 3 + 2 * 4 - 5?

    <p>6</p> Signup and view all the answers

    Which statement correctly subtracts 100 from the variable answer?

    <p>answer -= 100;</p> Signup and view all the answers

    What will the result be of assigning an integer value to a double variable?

    <p>It will be implicitly converted.</p> Signup and view all the answers

    In a mixed expression involving an integer and a double, what type will the result be?

    <p>Double</p> Signup and view all the answers

    What is the correct way to declare the CalcPay method with the required parameters?

    <p>static void CalcPay(float empTaxRate, double empSalary, out double empTax)</p> Signup and view all the answers

    Which statement about the return type of a method declared as type bool is correct?

    <p>It must return either true or false.</p> Signup and view all the answers

    In C#, what is the default type of parameters when passing them to methods?

    <p>Call by value</p> Signup and view all the answers

    Which of the following correctly describes a class in C#?

    <p>A blueprint for creating objects, which usually represents entities.</p> Signup and view all the answers

    Which of the following is true regarding instance methods in a class?

    <p>They are associated with a specific instance of the class.</p> Signup and view all the answers

    What can be inferred about method declarations that have no body?

    <p>They are abstract methods.</p> Signup and view all the answers

    When constructing an object, which of the following statements is true about data members?

    <p>Non-numeric data members can be initialized to null.</p> Signup and view all the answers

    What is the standard access modifier that should be defined for constructors?

    <p>public</p> Signup and view all the answers

    Study Notes

    C# Language Fundamentals

    • Console is a class, WriteLine() is a method within the class
    • _Main() method serves as the program's entry point.
    • The base-2 numeral system is also known as the binary number system.
    • The binary representation of the decimal value ten is 00001010.
    • A megabyte is approximately one million bytes.
    • An identifier named total$Amount is invalid because it uses a dollar sign ($). Only underscores are allowed.
    • C#'s naming convention follows Pascal case, where the first letter of each identifier is capitalized, and subsequent words have their first letter capitalized.
    • A valid C# identifier can use letters, numbers, and underscores. It must start with a letter or an underscore.
    • A valid compile-time initialization for a double variable amountDue set to zero is: double amountDue = 0;
    • Identifiers LeaveMap, ChooseTreasure, ActionHero, and WizardCastingSpell follow Pascal case naming convention.
    • Every C# data type has a corresponding class in the .NET Common Type System.
    • Reference types contain the memory address where the data is stored.
    • The C# char value type can store characters like '0', '1', '2', '3', 'x', 'y', and 'z'.

    Early Computing History

    • Charles Babbage's Analytical Engine was an important early mechanical computing device.
    • The ENIAC, the first general-purpose electronic computer, used vacuum tubes for its circuitry.
    • The Analytical Engine is considered the earliest prototype for a general-purpose computer.

    Software Development

    • Software consists of sets of instructions that direct the actions of a computer.
    • Understanding the problem definition is crucial during the first phase of software development.
    • An algorithm is a step-by-step process for solving a problem.
    • C# follows a set of rules called syntax that programmers must follow.
    • Procedural programming is also known as structured programming.
    • C# is object-oriented, so programs are built around classes.

    .NET Compilation and Execution

    • During .NET compilation, all programming languages are converted into Microsoft Intermediate Language (MSIL), which is not the machine code of the target computer.
    • The System namespace in C# contains classes for commonly used types.
    • A method call invokes a method, while a method declaration defines it.
    • Namespaces in C# group related types under a single name.

    C# Data Types

    • float values are represented as floating-point numbers and require the f or F suffix in initialization.
    • The scientific notation 3.42e-4 is equivalent to 0.000342.
    • The default data type for floating-point numbers in C# is double.
    • Use the decimal type for currency or financial values.
    • Implicit conversions occur when assigning integer values to decimal variables.
    • The bool data type in C# has values of either true or false.
    • “December” is a valid string literal representing the last month of the year.
    • String and object are built-in reference types in C#.
    • You can assign a variable to a constant, but not vice versa.
    • The modulus operator (%) returns the remainder of a division.
    • The ++ operator (increment) increases the value of a variable by one. It is used after the variable in the payment++ statement, so the value is increased after the value is used.
    • The -= operator subtracts a value from a variable.
    • The ++ operator (increment) increases the value of a variable by one. It is used before the variable in the ++payment statement, so the value is increased before it is used.
    • In a mixed expression with integer and double values, the result will be a double.
    • Assigning an integer to a double variable will not cause a syntax error.
    • Calling a function requires considering the function's defining header including parameters and return type.
    • A method declared as bool must return either true or false.
    • C# supports call-by-value and call-by-reference parameter passing. Call-by-value is the default.

    Classes in C#

    • A class is often associated with an entity, which represents a person, place, or thing.
    • Classes are used to define objects in C#, and all code is placed within at least one class.
    • Methods within a class are called instance methods.
    • Data members of a class (attributes) store information about an object.
    • The new keyword is used to call constructors when instantiating objects.
    • Data members of an object are not necessarily initialized to 0. Non-numeric data members are initialized to null.
    • Default constructors typically have an empty body.
    • Constructors should generally be declared with public access modifier.
    • Constructors are used to create objects, not the other way around
    • A property looks like a field and not like a method.
    • Accessors are used to get or set values of a property.
    • Instance methods of a class can manipulate data directly by accessing the private data members.
    • To override the ToString() method in a class, use the override keyword.
    • Invoking methods within a class is done using an object of that class.
    • Proper naming conventions are used when defining classes, properties, and methods.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Description

    Test your knowledge on the fundamentals of C#. This quiz covers essential topics such as the Console class, the Main method, binary number representation, and naming conventions for identifiers. Challenge yourself and see how well you understand the basics of C# programming!

    More Like This

    Use Quizgecko on...
    Browser
    Browser