What is shadowing?

Answers were Sorted based on User's Feedback



What is shadowing?..

Answer / manikandan

When global and local varible in the same name.
the local varibale in a mehod or function which use to
override the global is called the shadowing.
ie the Global varible is being shadowed by the
local varible

Is This Answer Correct ?    41 Yes 8 No

What is shadowing?..

Answer / sonia.sardana

If there are overloaded methods in the base class, & u
marks one of the methods as shadows using the keyword
shadow in the derived class, then we cannot access the
overloaded methods.

Ex-
public class base
public sub test()
console.writeline("sonia")
end sub

public sub test(i as integer)
console.writeline(i)
end sub

end class

public sub derived
inherirts base
shadows sub test(x as integer)
console.writeline("Shadow method")
end sub
end class


sub main()
dim obj as new derived
obj.test()-->Invalid
obj.test(10)-->Valid
end sub

Is This Answer Correct ?    22 Yes 5 No

What is shadowing?..

Answer / rohit

Whatever the code written by Sonia.sardana is shows the
shadowing concept but there is some print mistakes in the
code.The correct code is---


imports system
module m1
public class base
Public Sub test()
Console.WriteLine("sonia")
End Sub

Public Sub test(ByVal i As Integer)
Console.WriteLine(i)
End Sub

End Class

Public class derived
inherits base

Shadows Sub test(ByVal x As Integer)
Console.WriteLine("Shadow method")
End Sub
end class


Sub main()
Dim obj As New derived
obj.test() 'This will show error
obj.test(10) 'This is valid
End Sub

end module

Is This Answer Correct ?    8 Yes 6 No

What is shadowing?..

Answer / nand lal

shadowing in general is when two variables/methods or any
other element has same name and any one of the both can
shadow( in OOP case override) the behavior of other.

Is This Answer Correct ?    2 Yes 0 No

What is shadowing?..

Answer / rohatash

there are overloaded methods in the base class, & u
marks one of the methods as shadows using the keyword
shadow in the derived class, then we cannot access the
overloaded methods.
Module Module1

Class A
Public Sub Show()
Console.WriteLine("Calling from A")
End Sub
End Class

Class B
Inherits A
Public Shadows Sub Show()
Console.WriteLine("Calling from B")
End Sub
End Class

Class C
Inherits B
Public Shadows Sub Show()
Console.WriteLine("Calling from C")
End Sub
End Class

Class Test
Public Shared Sub Main()
Dim x As A
x = New A()
x.Show()
x = New B()
x.Show()
x = New C()
x.Show()
End Sub
End Class

End Module

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More VB.NET Interview Questions

what are the types of threading models in VB.net ?

1 Answers   Satyam,


What are the different variables in vb.net?

0 Answers  


What is private assembly?

0 Answers  


What are the difference between structure and class?

0 Answers  


What is portable executable?

0 Answers  






Sir, what code to store data from vb net sql server 2008 to 2005 and at the same time in order to validate the data entered is not the same, but there have been contacts in the module. Examples such as the log table that I created, the user name as the primary key.

0 Answers   Infosys,


hey friends, Firstly I pick the records from the database into the DataGridView, Then I want that If I made any changes to the records in the GridView & Click on Update Button, Changes are Reflected into the main Database .Plz do reply back

4 Answers  


Explain the observations between vb.net and vc#.net?

0 Answers  


Explain manifest?

0 Answers  


What is the use of console application?

0 Answers  


How to store jpeg / gif / bmp image in database and how to retrieve them? The most stressful condition is database is distributed and stored images can be retrive from any computer in network and any one can store images from other computer!! plss help its urgent.......RAHUL RATHOD

3 Answers  


How do you do multithreading application in VB ?

4 Answers   Satyam,


Categories