Java Essentials - Boolean type data in java
6K views
Nov 18, 2024
Java Essentials - Boolean type data in java
View Video Transcript
0:00
In this video we are discussing bullion type data in Java
0:04
We know that there is one data type available in Java that is a bullion data type
0:09
So in case of bullion data type, a variable can hold only two values
0:13
So the first value is true and another value can be the false
0:17
So let us discuss on them into details. So bullion type variables can have two possible values, either true or false
0:25
And these are one bit data. So, for the Boolean type of variables, one bit of memory space will be occupied and you can
0:33
represent true or false using single one or single zero. So the default value of Boolean type data is false here
0:43
So let us go for one practical demonstration to show you that how this sort of data type
0:49
variables can be used in our Java code. So here is a demonstration for you
0:54
In the demonstration, we are going to discuss Boolean type of variables. that is the my bull so bullion my bull so my bull is a variable of the type bullion my bull has got
1:05
initialized with the value that is true here you can find that in case of true all the letters are
1:10
written in the lower case and then we are trying to print the value of my bull there and my bull is
1:16
equal to false we setting the value of my bull with false that is we know that bullian data type can have two values either true or false and then it is printing that my bull there so let me go
1:27
for the execution you can find for the first time my bull has got printed as true for the second time my bull has got printed as false so now let me go
1:36
for some other experiments here I'm writing here 100
1:47
so now if i go on printing i'm finding that it is producing error because proceed you can find
1:54
that it is producing error because this my bull cannot hold any other data types value it can hold
2:00
only true and false as it is showing the respective error message so the error message is showing
2:05
that exception in thread main java. langddd error unresolved compilation problem type mismatch
2:12
cannot convert to i nt or bullion i from i nt to bullion because
2:17
100 was I and t it cannot be converted to bullion and that's why it is producing one error at the line number 13 here for this respective Java code so that's why you can find that this particular bullion variable can hold only the value true and false cannot hold the value of any other data types data so that's why in this demonstration we have given you the idea how to deal with the bullion type of variable thanks for watching this video
#Computers & Electronics
#Java (Programming Language)
#Programming