Equivocal
Equivocal

Reputation: 932

What is the difference between "Explicitly" and "Implicitly" in programming language?

I would like to have a clear and precise understanding of the difference between the two.

Also is the this keyword used to implicitly reference or explicitly ? This is also why I want clarification between the two?

I assume to use the this keyword is to reference implicitly (being something withing the class) whilst explicitly (is something not belonging to the class itself) like a parameter variable being passed into a method.

Of course my assumptions could obviously be wrong which is why I'm here asking for clarification.

Upvotes: 14

Views: 34647

Answers (5)

JQTs
JQTs

Reputation: 310

This was way more complicated than I think it needed to be:

explicit = label names of a index (label-based indexing) example:

df['index label name']

vs

implicit = integer of index (zero-based indexing)

df[0]

Upvotes: 0

Abdul Rizwan
Abdul Rizwan

Reputation: 4108

already you have got your answer but I would like to add few more.

Implicit: which is already available into your programming language like methods, classes , dataTypes etc.

-implicit code resolve the difficulties of programmer and save the time of development.

-it provides optimised code. and so on.

Explicit: which is created by the programmer(you) as per their(your) requirement, like your app class, method like getName(), setName() etc.

finally in simple way, A pre-defined code which provides help to programmer to build their app,programs etc it is know as implicit, and which have been written by the (you)programmer to full fill the requirement it is known as Explicit.

Upvotes: 7

Akash Mishra
Akash Mishra

Reputation: 712

I'll try to provide an example of a similar functionality across different programming languages to differentiate between implicit & explicit.

Implicit: When something is available as a feature/aspect of the programming language constructs being used. And you have to do nothing but call the respective functionality through the API/interface directly.

For example Garbage collection in java happens implicitly. The JVM does it for us at an appropriate time.

Explicit: When user/programmer intervention is required to invoke/call a specific functionality, without which the desired action wont take place.

For example, in C++, freeing of the memory (read: Garbage collection version) has to happen by explicitly calling delete and free operators.

Hope this helps you understand the difference clearly.

Upvotes: 4

kishan sahu
kishan sahu

Reputation: 151

1: Implicit casting (widening conversion)

A data type of lower size (occupying less memory) is assigned to a data type of higher size. This is done implicitly by the JVM. The lower size is widened to higher size. This is also named as automatic type conversion.

Examples:

    int x = 10;                    // occupies 4 bytes
    double y = x;                  // occupies 8 bytes
    System.out.println(y);         // prints 10.0

In the above code 4 bytes integer value is assigned to 8 bytes double value.

  1. Explicit casting (narrowing conversion)

A data type of higher size (occupying more memory) cannot be assigned to a data type of lower size. This is not done implicitly by the JVM and requires explicit casting; a casting operation to be performed by the programmer. The higher size is narrowed to lower size.

   double x = 10.5;             // 8 bytes
   int y = x;                   // 4 bytes ;  raises compilation error

1 2 double x = 10.5; // 8 bytes int y = x; // 4 bytes ; raises compilation error In the above code, 8 bytes double value is narrowed to 4 bytes int value. It raises error. Let us explicitly type cast it.

   double x = 10.5;                  
   int y = (int) x; 

1 2 double x = 10.5;
int y = (int) x; The double x is explicitly converted to int y. The thumb rule is, on both sides, the same data type should exist.

Upvotes: 5

momomorez
momomorez

Reputation: 545

Explicit means done by the programmer. Implicit means done by the JVM or the tool , not the Programmer.

For Example: Java will provide us default constructor implicitly.Even if the programmer didn't write code for constructor, he can call default constructor.

Explicit is opposite to this , ie. programmer has to write .

Upvotes: 31

Related Questions