What is the difference between the new operator and modifier?

1 Answer

Answer :

The new operator creates an instance of a class whereas the new modifier is used to declare a method with the same name as a method in one of the parent classes.

Related questions

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

Last Answer : No

Description : Define what is a New modifier?

Last Answer : The new modifier hides a member of the base class. C# supports only hide by signature.

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 : Describe the accessibility modifier “protected internal”. 

Last Answer : It is available to classes that are within the same assembly and derived from the specified base class.

Description : Can properties have an access modifier?

Last Answer : Yes

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 : Describe the accessibility modifier “protected internal”. 

Last Answer : It is available to classes that are within the same assembly and derived from the specified base class.

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 : Describe the accessibility modifier protected internal. 

Last Answer : It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in). 

Description : Write some code to overload an operator. 

Last Answer : class TempleCompare { public int templeCompareID; public int templeValue; public static bool operator == (TempleCompare x, TempleCompare y) { return (x.templeValue == y.templeValue); } ... templeValue); } public override int GetHashCode() { return templeCompareID; } }

Description : What does operator order of precedence mean? 

Last Answer : Certain operators are evaluated before others. Brackets help to avoid confusion. 

Description : Describe an operator from each of these categories:

Last Answer : Arithmetic: + Logical (boolean and bitwise): & String concatenation: + Increment, decrement: ++ Shift: >> Relational: == Assignment: = Member access: . Indexing: [] Cast: () ... : + Object creation: new Type information: as Overflow exception control: checked Indirection and Address: *

Description : Can operator parameters be reference parameters?

Last Answer : No

Description : What doe the stackalloc operator do?

Last Answer : Allocate a block of memory on the stack (used in unsafe mode).  

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 : Explain the difference between Globalization and Localization.

Last Answer : Globalization refers to the application of culture-specific format to existing data. Localization refers to providing new culture-specific resources and retrieving the appropriate resources based on the culture setting. 

Description : Briefly explain the difference between Public (public), Friend (internal), and Private (private) access levels as they apply to user-defined types and members.

Last Answer : In user-defined types, Public (public) classes can be instantiated by any element of the application. Friend (internal) classes can be instantiated only by members of the same assembly, and Private ( ... the same assembly, and Private (private) members can be accessed only from within the type. 

Description : What’s the difference between private and shared assembly? 

Last Answer : Answer: Privateassembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name.

Description : What is the difference between a namespace and an assembly name?

Last Answer : A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under ... design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

Description : What’s the difference between the Debug class and Trace class? 

Last Answer : Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

Description : What’s the difference between // comments, /* */ comments and /// comments?

Last Answer : Single-line comments, multi-line comments, and XML documentation comments.

Description : What is the difference between a Struct and a Class? 

Last Answer : Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.

Description : What’s the difference between an interface and abstract class?

Last Answer : Answer: An abstract class and Interface both have method only but not have body of method.The difference between Abstract class and An Interface is that if u call Ablstract class then u have to call ... type, Parameter type, Parameter Number all must be same . Only body of method can change. 

Description : What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

Last Answer : The first one performs a deep copy of the array, the second one is shallow. 

Description : What’s the difference between System.String and System.Text.StringBuilder classes?

Last Answer : System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

Description : What’s the difference between camel and pascal casing?

Last Answer : PascalCasing, camelCasing 

Description : In terms of constructors, what is the difference between: public MyDerived() : base() an public MyDerived() in a child class?

Last Answer : Nothing

Description : What’s the difference between the Debug class and Trace class? 

Last Answer : Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.

Description : What’s the difference between // comments, /* */ comments and /// comments?

Last Answer : Single-line comments, multi-line comments, and XML documentation comments.

Description : What is the difference between a Struct and a Class?

Last Answer : Structs are value-type variables and are thus saved on the stack, additional overhead but faster retrieval. Another difference is that structs cannot inherit.

Description : What’s the difference between the System.Array.CopyTo() and System.Array.Clone()?

Last Answer : The Clone() method returns a new array (a shallow copy) object containing all the elements in the original array. The CopyTo() method copies the elements into another existing array. Both perform a ... create a new instance of each element's object, resulting in a different, yet identacle object.

Description : What’s the difference between System.String and System.Text.StringBuilder classes?

Last Answer : System.String is immutable. System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

Description : What’s the difference between System.String and System.StringBuilder classes?

Last Answer : System.String is immutable, System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.

Description : Define what are the difference between const and readonly?

Last Answer : A const cannot be static, while readonly can be static. A const need to be declared and initialized at declaration only, while a readonly can be initialized at the declaration or by the code in the ... A const's value is evaluated at design time, while a read-only value is evaluated at runtime.

Description : Define what is the difference between an abstract method & virtual method?

Last Answer : An Abstract method does not provide an implementation and forces overriding to the deriving class (unless the deriving class also an abstract class), whereas the virtual method has an ... abstract method does not provide implementation & forces the derived class to override the method.

Description : Define what is the difference between a class and an Interface?

Last Answer : 1. Abstract classes can have implementations for some of its members, but the interface can't have implementation for any of its members. 2. Interfaces cannot have fields whereas an ... 5. Abstract class members can have access modifiers whereas interface members cannot have access modifiers.

Description : Define what is the main difference between a sub procedure and a function?

Last Answer : Sub procedures do not return a value, while functions do.

Description : Define what is a basic difference between the while loop and do-while loop in C#?

Last Answer : The while loop tests its condition at the beginning, which means that the enclosed set of statements run for zero or more number of times if the condition evaluates to true. The do while loop iterates a set of statements at least once and then checks the condition at the end.

Description : Define what is the difference between compile-time polymorphism and run-time polymorphism?

Last Answer : Compile time Polymorphism Compile time Polymorphism also known as method overloading. Method overloading means having two or more methods with the same name but with different signatures. Run time ... or more methods with the same name, same signature but with a different implementation.

Description : Define what is the difference between Shadowing and Overriding?

Last Answer : Overriding redefines only the implementation while shadowing redefines the whole element. In overriding derived classes can refer the parent class element by using “ME” keyword, but in shadowing you can access it by “MY BASE”.

Description : Define what is the main difference between a sub procedure and a function?

Last Answer : Sub procedures do not return a value, while functions do.

Description : Define what is the difference between CONST and READONLY?

Last Answer : Both are meant for constant values. A const field can only be initialized at the declaration of the field. A read-only field can be initialized either at the declaration or.

Description : Define what is the difference between Array and LinkedList?

Last Answer : The array is a simple sequence of numbers which are not concerned about each other’s positions. they are independent of each other’s positions. adding, removing or modifying any array element is very easy. Compared to arrays, a linked list is a complicated sequence of numbers.

Description : Define what is the difference between console and window application?

Last Answer : A console application, which is designed to run at the command line with no user interface. A Windows application, which is designed to run on a user’s desktop and has a user interface.

Description : Define what is the difference between Array and ArrayList?

Last Answer : An array is a collection of the same type. The size of the array is fixed in its declaration. A linked list is similar to an array but it doesn’t have a limited size.

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 the difference between break and continue statement?

Last Answer : The break statement is used to terminate the current enclosing loop or conditional statements in which it appears. We have already used the break statement to come out of switch statements. The ... statement stops the current iteration and simply returns control back to the top of the loop.

Description : Define what is the difference between value type and reference type?

Last Answer : 1. Value types are stored on the stack and when a value of a variable is assigned to another variable. 2. Reference types are stored on the heap, and when an assignment between two reference variables occurs.

Description : Define what is the difference between Custom Control and User Control?

Last Answer : Custom Controls have compiled the code (DLLs), easier to use, difficult to create, and can be placed in toolbox. Drag and Drop controls. Attributes can be set visually at design time. Can be ... the toolbox and dragged - dropped from it. A User Control is shared among the single application files.

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.