Methods must declare a return type, what is the keyword used when nothing is returned from the method?

1 Answer

Answer :

void 

Related questions

Description : What does the keyword “virtual” declare for a method or property? 

Last Answer : The method or property can be overridden. 

Description : What does the keyword “virtual” declare for a method or property? 

Last Answer : The method or property can be overridden.

Description : Class methods to should be marked with what keyword?

Last Answer : static

Description : What si the difference between interface and abstractclass Select Answer:  1. interface contain only methods  2. we can't declare a variable for interface  3. interface contain only events  4. None  5. All

Last Answer : Ans : 2 The only Difference between Interface and Abstract class is we can declare a variable in abstract class but we can't declare in variable interface

Description : In C++, the keyword void was used ……….. A) To specify the return type of function when it is not returning any value. B) To indicate an empty argument list to a function. C) To declare the generic pointers. D) All of the above.

Last Answer : D) All of the above.

Description : What does the keyword virtual mean in the method definition? 

Last Answer : The method can be over-ridden. 

Description : Can you declare an override method to be static if the original method is not static? 

Last Answer : No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)

Description : Can you declare an override method to be static if the original method is not static? 

Last Answer : No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)

Description : Can you declare the override method static while the original method is nonstatic?

Last Answer : No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override. 

Description : Can we declare a method as sealed?

Last Answer : In C# a method can’t be declared as sealed. However, when we override a method in a derived class, we can declare the overridden method as sealed. By declaring it as sealed, we can avoid further overriding of this method.

Description : Write code to use threading and the lock keyword. 

Last Answer : using System; using System.Threading; namespace ConsoleApplication4 { class Class1 { [STAThread] static void Main(string[] args) { ThreadClass tc1 = new ThreadClass(1); ThreadClass tc2 = new ThreadClass( ... Console.WriteLine(threadNumber + " working"); Thread.Sleep(1000); } } } } }

Description : What is the volatile keyword used for?

Last Answer : It indicates a field can be modified by an external entity (thread, OS, etc.). 

Description : What keyword would you use for scope name clashes?

Last Answer : this

Description : Why is the virtual keyword used in code?

Last Answer : The Virtual keyword is used in code to define methods and the properties that can be overridden in derived classes.

Description : Define what is the use of the abstract keyword?

Last Answer : The modifier abstract is a keyword used with a class, to indicate that this class cannot itself have direct instances or objects, and it is intended to be only a ‘base’ class to other classes.

Description : Define what is the difference between string keyword and System. String class?

Last Answer : String keyword is an alias for System. String class. Therefore, the System. String and string keyword are the same, and you can use whichever naming convention you prefer. The String class provides many methods for safely creating, manipulating, and comparing strings.

Description : Explain the “static” keyword in C#?

Last Answer : “Static” keyword can be used for declaring a static member. If the class is made static then all the members of the class are also made static. If the variable is made static then it will have a single instance and the value change is updated in this instance.

Description : Why use the keyword “const” in C#? Give an example.

Last Answer : “Const” keyword is used for making an entity constant. We can’t reassign the value to constant. Eg: const string _name = “Test”;

Description : When do you absolutely have to declare a class as abstract?

Last Answer : 1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. 2. When at least one of the methods in the class is abstract.

Description : Write some code to declare and use properties.

Last Answer : // instance public string InstancePr { get { return a; } set { a = value; } } //read-only static public static int ClassPr { get { return b; } }

Description : How do you declare a constant? 

Last Answer : public const int c1 = 5; 

Description : When do you absolutely have to declare a class as abstract?

Last Answer : 1. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden. 2. When at least one of the methods in the class is abstract.

Description : When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?

Last Answer : When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been overridden.

Description : Can we declare a block as static in c#?

Last Answer : No, because c# does not support static block, but it supports static method.

Description : Explain how to use the Begin and End methods on a Web Service to make an asynchronous method call.

Last Answer : Every public Web method on a Web Service can be called either synchronously or asynchronously. To make an asynchronous call to a Web method, you call the method named Begin, where is the name of ... returned by Begin. This will allow you to retrieve the actual data returned by the Web method.

Description : Do events have return type?

Last Answer : No, events do not have a return type.

Description : What are the two return types for main? 

Last Answer : void and int

Description : Define what is the use of the return statement?

Last Answer : The return statement is associated with procedures (methods or functions). On executing the return statement, the system passes the control from the called procedure to the calling procedure. This ... the currently executed code to return some value to the caller of the currently executed code.

Description : Describe Break mode and some of the available methods for navigating in Break mode.

Last Answer : Break mode allows you to observe program execution on a line-by-line basis. You can navigate program execution in Break mode by using Step Into, Step Over, Step Out, Run To Cursor, and Set Next Statement.

Description : Why can’t you specify the accessibility modifier for methods inside the interface?

Last Answer : They all must be public, and are therefore public by default. 

Description : Can abstract methods override virtual methods? 

Last Answer : Yes

Description : Can a struct have methods?

Last Answer : Yes

Description : Write some code using interfaces, virtual methods, and an abstract class.

Last Answer : using System; public interface Iexample1 { int MyMethod1(); } public interface Iexample2 { int MyMethod2(); } public abstract class ABSExample : Iexample1, Iexample2 { public ABSExample( ... override void VIRTMethod2() { System.Console.WriteLine("VIRTMethod2 has been overridden"); } }

Description : Why can’t you specify the accessibility modifier for methods inside the interface?

Last Answer : They all must be public, and are therefore public by default.

Description : Why can’t you specify the accessibility modifier for methods inside the interface? 

Last Answer : They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.

Description : Can you override private virtual methods? 

Last Answer : No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access. 

Description : Can you override private virtual methods?

Last Answer : No. Private methods are not accessible outside the class.

Description : Can you override private virtual methods?

Last Answer : No, private methods are not accessible outside the class.

Description : Define what is the difference between static and instance methods?

Last Answer : A method declared with a static modifier is a static method. A static method does not operate on a specific instance and can only access static members. A method declared without a static modifier is an ... can be explicitly accessed as this. It is an error to refer to this in a static method.

Description : Define what is methods?

Last Answer : A method is a member that implements a computation or action that can be performed by an object or class. Static methods are accessed through the class. Instance methods are accessed through instances of the class.

Description : Define what is the difference between “throw ex” and “throw” methods in C#?

Last Answer : “throw ex” will replace the stack trace of the exception with stack trace info of rethrowing point. “throw” will preserve the original stack trace info.

Description : Define what is the difference between “finalize” and “finally” methods in C#?

Last Answer : Finalize – This method is used for garbage collection. So before destroying an object, this method is called as part of the cleanup activity. Finally – This method is used for executing the code irrespective of exception occurred or not.

Description : Explain when a type conversion will undergo an implicit cast and when you must perform an explicit cast. What are the dangers associated with explicit casts?

Last Answer : Types can be implicitly converted when the conversion can always take place without any potential loss of data. When a potential loss of data is possible, an explicit cast is required. If an explicit cast is improperly performed, a loss of data precision can result, or an exception can be thrown.

Description : what does the term keyword prominence refer to? A. It refers to the importance attached to getting the right keyword density.  B.It refers to the fact that the keywords in bold font are ... fact that the keywords placed in important parts of a webpage are given priority by the search engines

Last Answer : D.It refers to the fact that the keywords placed in important parts of a webpage are given priority by the search engines

Description : What is the use of return keyword?

Last Answer : A: return keyword is used to return any value from a function. It denotes the end of a function.

Description : An operator declaration must include a public and static modifier, can it have other modifiers?

Last Answer : No

Description : What is method overloading, and when is it useful?

Last Answer : Method overloading allows you to create several methods with the same name but different signatures. Overloading is useful when you want to provide the same or similar functionality to different sets of parameters.

Description : What does the Dispose method do with the connection object? 

Last Answer : Deletes it from the memory. To Do: answer better. The current answer is not entirely correct.

Description : What does assert() method do?

Last Answer : In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.