Question

In C# Customer is a static class, and Buy() is a static method of the class...

In C#

Customer is a static class, and Buy() is a static method of the class Customer. To call the method Buy(), I should write:

Homework Answers

Answer #1

Answer::

I am explaining the question with help of small program which will help you to understand.And also I have added information related to it as comments in program.

using System;
//static class Customer
public static class Customer
{
  //static method Buy()
  public static void Buy()
  {
    Console.WriteLine("Buy() method called"); //some statements
  }
}
class MainClass {
  public static void Main (string[] args) {
    //Here we are calling our static Buy() method of static class Customer 
    //In C#, static means something which cannot be instantiated. You cannot create an object of a static class and cannot access static members using an object.
    //you can user Class name while calling a method of that class.
    Customer.Buy();  
   
  }
}

Output::

  

Use the above as reference.If any problem comment.

Know the answer?
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
Similar Questions
Java Programing Exercise #3: Write a Java class that implements a static method – SortNumbers(int… numbers)...
Java Programing Exercise #3: Write a Java class that implements a static method – SortNumbers(int… numbers) with variable number of arguments. The method should be called with different numbers of parameters and does arrange the numbers in descending order. Call the method within main method of the driver classand display the results.
-Previously - java class with one static method. In the static method called beforeThis. take 2...
-Previously - java class with one static method. In the static method called beforeThis. take 2 strings as inputs and return a string. Code for the method should look for 1st input String within the 2nd input, and return everything from 2nd input string that comes before. ex: 1st input : "tennis" 2nd input : "A tabletennis is in the basement" method returns: "A table"
1.If you have defined a class,  SavingsAccount, with a public  static method,  getNumberOfAccounts, and created a  SavingsAccount object referenced by...
1.If you have defined a class,  SavingsAccount, with a public  static method,  getNumberOfAccounts, and created a  SavingsAccount object referenced by the variable  account20, which of the following will call the  getNumberOfAccounts method? a. account20.getNumberOfAccounts(); b. SavingsAccount.account20.getNumberOfAccounts(); c. SavingsAccount.getNumberOfAccounts(); d. getNumberOfAccounts(); e. a & c f. a & b 2.In the following class, which variables can the method printStats use? (Mark all that apply.) public class Item { public static int amount = 0; private int quantity; private String name; public Item(String inName, int inQty) { name...
Please answer quickly! Thank you. Java: Write a non-static method to be added to a class...
Please answer quickly! Thank you. Java: Write a non-static method to be added to a class that implements a singly linked list of integers. The method is called make_partition() and takes an integer x as input. The method should modify this list by moving all the elements less than x to the front of the list, and all the elements greater than x to the back of the list. It is not the important for the elements to be kept...
Write a parent class Rectangle in Java with an area calculation method in dynamic binding and...
Write a parent class Rectangle in Java with an area calculation method in dynamic binding and another area calculation method in static binding. Write a child class Square with an area calculation method that overrides the Rectangle class’s area method. ( in Java use static or final for static binding.) Write a main program that calls both the dynamically bound method and the statically bound method a large number of times (say 1000 times), timing the calls to static binding...
Write a recursive method public static int sumEveryOther(int n) that takes a positive int as an...
Write a recursive method public static int sumEveryOther(int n) that takes a positive int as an argument and returns the sum of every other int from n down to 1. For example, the call sumEveryOther(10) should return 30, since 10 + 8 + 6 + 4 + 2 = 30. The call sumEveryOther(9) should return 25 since 9 + 7 + 5 + 3 + 1 = 25. Your method must use recursion.
C Programming 1. Provide an equivalent of the java class in C class Example { public...
C Programming 1. Provide an equivalent of the java class in C class Example { public static int[][] question4(int n) { int[][] result = new int [n][n]; for(int i=1; i<=n; i+=1) for (int j=1; j<=n; j+=1) result[i][j] = (i*n)+j; return result; } public static void main(String[] args) { int[][] my array = question4(4); } } 2. Rewrite the following function using no loops, and only tail call recursion int min (int n, int[] input) { int i; int result; for...
Write a method in class SLL<T> called public static SLL<T> reverse() that produces a new linked...
Write a method in class SLL<T> called public static SLL<T> reverse() that produces a new linked list with the contents of the original list reversed. Make sure not to use any methods like addToHead() or addToTail(). In addition, consider any special cases that might arise. (b) What is the big-O complexity of your method in terms of the list size n.
The keyword static when applied to a field means what:    There is a copy of...
The keyword static when applied to a field means what:    There is a copy of the field for each class object.     The field may be accessed only by the constructor of the class.     Only one copy of the field in memory     The field is subject to garbage collection. What does it mean for a class method to be static?    It means the method is private.     It means the method is public.     It means...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {       ...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {        Stack<Integer> new_stack = new Stack<>();/* Start with the empty stack */        Scanner scan = new Scanner(System.in);        int num;        for (int i=0; i<10; i++){//Read values            num = scan.nextInt();            new_stack.push(num);        }        int new_k = scan.nextInt(); System.out.println(""+smallerK(new_stack, new_k));    }     public static int smallerK(Stack s, int k) {       ...