Can you allow a class to be inherited, but prevent the method from being overridden?

1 Answer

Answer :

Yes. Just leave the class public and make the method sealed

Related questions

Description : Can you allow class to be inherited, but prevent the method from being overridden? 

Last Answer : Yes, just leave the class public and make the method sealed. 

Description : Can you prevent your class from being inherited by another class?

Last Answer : Yes. The keyword “sealed” will prevent the class from being inherited.

Description : What is Finalize() Method of Object class?

Last Answer : Each class in C# is automatically (implicitly) inherited from the Object class which contains a method Finalize(). This method is guaranteed to be called when your object is garbage collected

Description : What is Static Method of the class?

Last Answer : Methods that you can call directly without first creating an instance of a class. 1. As static methods may be called without any reference to object

Description : Can you allow a class to be inherited, but prevent the method from being over-ridden?

Last Answer : Yes. Just leave the class public and make the method sealed. 

Description : Can you allow a class to be inherited, but prevent the method from being over-ridden?

Last Answer : Yes. Just leave the class public and make the method sealed. 

Description : What is a Class?

Last Answer : A user-defined data structure that groups properties and methods. Class doesn’t occupies memory.

Description : Whait is Method overriding?

Last Answer : Method overriding occurs when child class declares a method that has the same type arguments as a method declared by one of its superclass. By declaring base class function as virtual, we allow the function to be overridden in any of derived class

Description : What is a Method Overloading?

Last Answer : Method with same name but with different arguments is called method overloading

Description : What is the difference between the destructor and the Finalize() method? When does the Finalize() method get called?

Last Answer : Finalize() corresponds to the .Net Framework and is part of the System.Object class. Destructors are C#'s implementation of the Finalize() method. The functionality of both Finalize() and the destructor is the same

Description : What is Interface?

Last Answer : An Interface is a group of constants and method declaration interface like classes, define a set of properties, methods, and events. But unlike classes, interfaces do not provide implementation

Description : How many types of Access Modifiers?

Last Answer : Public – Allows the members to be globally accessible. Private – Limits the member’s access to only the containing type. Protected – Limits the member’s access to the containing type and all classes derived from the containing type. Internal – Limits the member’s access to within the current project

Description : What is Polymorphism?

Last Answer : Polymorphism means same operation may behave differently on different classes. Example : 1. Method Overloading and Method Overriding

Description : Is .NET C# supports Multiple inheritance?

Last Answer : Multiple inheritance of classes is not allowed in C#. but In C# you can implements more than one interface, thus multiple inheritance is achieved through interface

Description : What are Sealed Classes in C#?

Last Answer : The sealed modifier is used to prevent derivation from a class

Description : What is an Inheritance?

Last Answer : The process of sub-classing a class to extend its functionality is called Inheritance. Advantage : It provides idea of reusability.

Description : What is ref keyword & out keyword?

Last Answer : Refrence Variable “must” be initialized before it is passed into a method.

Description : What is Value Type and Reference Type?

Last Answer : A variable is value type or reference type is solely determined by its data type. Ex: int, float, char, decimal, bool, decimal, struct, etc are value types As name suggest Reference Type stores reference to the ... ; Y = X; Console.writeline(Y.value); Y.value = 50; Console.writeline(X.value);

Description : What is Enumeration?

Last Answer : Enumeration improves code readability. It also helps in avoiding typing mistake

Description : What is a Garbage collection?

Last Answer : Garbage collection is the mechanism that reclaims the memory resources of an object when it is no longer referenced by a variable. And Net Runtime performs automatically performs garbage collection

Description : What is Destructor?

Last Answer : A destructor is just opposite to constructor. it has same as the class name, but with prefix ~ (tilde). They do not have return types

Description : What is Static Constructor?

Last Answer : In C# it is possible to write a static no-parameter constructor for a class. Such a class is executed once, when first object of class is created. Class MyClass { static MyClass() { //Initialization Code for static fields and properties. } }

Description : What is static member of a calss?

Last Answer : Static members belong to the whole class rather than to individual object Static members are accessed with the name of class rather than reference to objects

Description : What is Constructor?

Last Answer : A constructor is a special method whose task is to initialize the object of its class. 1. It is special because its name is the same as the class name 2. They do not have return ... can call the base class constructor 4. Constructor is invoked whenever an object of its associated class is created

Description : Whar are properties?

Last Answer : Attribute of object is called properties Example:- A car has color as property.

Description : What is an encapsulation?

Last Answer : Wrapping up of data and function into a single unit is known as Encapsulation.

Description : What is an Object?

Last Answer : Instance of Class is called object. An object is created in memory using keyword “new”.

Description : Can you prevent your class from being inherited by another class?

Last Answer : Yes. The keyword “sealed” will prevent the class from being inherited. 

Description : Can you prevent your class from being inherited by another class? 

Last Answer : Yes. The keyword “sealed” will prevent the class from being inherited.

Description : Can you prevent your class from being inherited and becoming a base class for some other classes?

Last Answer : Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.

Description : State true of false. i) AWT is an extended version of swing ii) Paint( ) of Applet class cannot be overridden A) i-false, ii-false B) i-false,ii-true C) i-true, ii-false D) i-true, ii-true

Last Answer : A) i-false, ii-false

Description : Which of the following differentiates between overloaded functions and overridden functions ? (A) Overloading is a dynamic or runtime binding and overridden is a static or compile time binding. ... function overloading, while redefining a function in a friend class is called function overriding.

Last Answer : (B) Overloading is a static or compile time binding and overriding is dynamic or runtime binding.

Description : Can we reduce the visibility of the overridden method ?

Last Answer : Ans. No

Description : In terms of references, how do == and != (not overridden) work?

Last Answer : They check to see if the references both point to the same object. 

Description : What convincing argument was made by Anne? i) She was talkative just like any other student in the class. ii) She had the right to be talkative, as it was a classroom and not a prison. iii) ... being talkative. iv) She found it impossible to be quiet like the others as she couldn t change herself.

Last Answer : iii) She had inherited the trait from her mother, so couldn‘t stop being talkative.

Description : If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?

Last Answer : Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

Description : Are private class-level variables inherited? 

Last Answer : Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

Description : If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?

Last Answer : Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

Description : Are private class-level variables inherited? 

Last Answer : Yes, but they are not accessible. Although they are not visible or accessible via the class interface, they are inherited.

Description : If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor? 

Last Answer : Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class. 

Description : Are private class-level variables inherited? 

Last Answer : Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.

Description : Are constructors inherited? Can a subclass call the parent's class constructor? When?

Last Answer : Ans. You cannot inherit a constructor. That is, you cannot create a instance of a subclass using a constructor of one of it's superclasses. One of the main reasons is because ... developer the ability to override a superclasses constructor you would erode the encapsulation abilities of the language.

Description : Which of the following, in C++, is inherited in a derived class from base class ? (A) constructor (B) destructor (C) data members (D) virtual methods

Last Answer : (C) data members

Description : Which of the following statement(s) with regard to an abstract class in JAVA is/are TRUE? I. An abstract class is one that is not used to create objects. II. An abstract class is designed only to act as a base class ... by other classes. (1) Only l (2) Only II (3) Neither I nor II (4) Both l and II

Last Answer : Both l and II

Description : Is being messy inherited or is it a lifestyle choice?

Last Answer : It is in the child's genes. It can be inherited from both parents or members who are in the family tree. I do believe that some traits of a child can be corrected. It is a matter of being patient.

Description : Which type of Mendelian inherited condition results in both genders being affected equally in a vertical pattern? a) Automosomal dominant inheritance An individual who has an autosomal dominant ... that combine during early embryonic development leading to incomplete closure of the neural tube.

Last Answer : a) Automosomal dominant inheritance An individual who has an autosomal dominant inherited condition carries a gene mutation for that condition on one chromosome of a pair.

Description : Is there a technical reason that would prevent the creators of Fluther to allow us to post pictures directly into our posts, rather than just a link?

Last Answer : There is no technical reason, they probably just don’t want to have to bother with hosting images, or having them break the layout.

Description : In heating frozen foods in sealed pouches in microwaves, why do you first poke holes in the pouch? (1) To prevent the steam pres-sure from bursting open the pouch (2) To allow the heat to get into ... into the food through the holes (4) To allow the aroma of the food to come out through the holes

Last Answer : (1) To prevent the steam pres-sure from bursting open the pouch Explanation: Anything in a tight skin or shell can explode in a microwave because the water inside can expand and burst through. It ... of shells and holes should be poked in the plastic wrap or sealed pouches of frozen packaged foods.

Description : On electrical generators one of the bearings is isolated from the bedplate. This insulating block should not be painted and must be kept clean to ___________. A. protect operating personnel from shock ... the prime mover as it warms up D. eliminate shaft currents to prevent damaging the bearings

Last Answer : Answer: D

Description : When charging lead-acid batteries, the charging rate should be reduced as the battery nears its full charge to ____________. A. prevent damaging battery plates B. allow equalization of cell voltages C. reduce lead sulfate deposits D. increase lead peroxide formation

Last Answer : Answer: A