declare

Java Programming Tutorial 83 - Virtual in Java



Sharing buttons:

hey what's going on guys this video I

wanted to talk about a computer science

concept known as virtual and we're going

to put that in the context of Java and

see what that means exactly pram is a

free mock interview platform where you

can develop your technical interviewing

skills practice coding with live

execution of all major programming

languages to solve real interview

questions interview types include data

structures and algorithms product

management behavioral interviews system

design front-end and data science I've

personally used this service to

successfully crash course for a software

engineering interview lots of people are

having success getting positions at

companies like Amazon Google Twitter and

more check it out I'll leave a link for

you guys in the description now

throughout the last couple in-person

videos we have talked about how we can

override methods and how we can use

inheritance to pass down methods from

derived classes so think of it like this

we have a method we'll call it hello and

then we can override this like so so

this came from a base class this one

from a derived class now if we typed out

this method gave it a body then we would

be overriding this one here now in

computer science in order for us to

override a method from a derived class

this method needs to be labeled virtual

but before you start typing out virtual

and stuff inside of Java you do not have

to type virtual because it's done

implicitly so in other words all methods

there's some exceptions I'll tell you

about in a second most methods are going

to be virtual by default so you don't

have to type anything out and in the

derived class we don't have to say

override or do anything fancy either so

I did mention there were some exceptions

and not all of them are virtual well the

ones that are not virtual are static

methods and in addition to this private

methods are not going to be virtual as

well which makes sense because if a

method is private it's only there inside

of that class now I would encourage you

to look up the details of the concept of

methods being virtual because you should

understand how it works and

you might also get some more information

on the exceptions when the implicit

virtual is not a thing and so forth

so in conclusion Java makes our lives

pretty darn easy because we don't have

to do any extra typing we can basically

create that method in any of our derived

classes and it's automatically going to

override any of the methods higher up in

the hierarchy the inheritance chain so

thank you guys for watching stay tuned

for the next videos because we're going

to get some more hands-on practice and

some other good concept so I'll see you

then and be sure to subscribe

[Music]