+ 11

What is difference between implicit and explicit in java?

29th Apr 2019, 9:41 AM
Nasir❀
Nasir❀ - avatar
3 Answers
+ 11
Explicit means somthing is done by the programmer Implicit means that its done by the complier. for example if you dont explicitly create a constructor for your class the compiler will implicitly create default one for you.
29th Apr 2019, 9:46 AM
D_Stark
D_Stark - avatar
+ 8
D_Stark please give an example using programme.
29th Apr 2019, 10:02 AM
Nasir❀
Nasir❀ - avatar
+ 6
In general terms like these are used in type conversion In implicit conversion the data type of the variable is converted to the highest data type (Hierachy ) present in the expression For eg: int a double b c=a+b In this the compiler will convert the value in double which is highest in expression Explicit is forced conversion done using type cast operator for eg int a double b s=(int) a+b In this the sum would be converted into int type Hope it helps
12th May 2019, 6:16 AM
Ayush Pandey
Ayush Pandey - avatar