How does generateFromLink work? How the generateFromLink method works ? And how to use it in the render array.  What is the difference between this method and the other methods used to generate link ?
$url = new Url('test_route_1');

$link = new Link('Test', $url);

$generated_link = \Drupal::service('link_generator')-&gt;generateFromLink($link);
You shouldn't use this service because it is marked as internal and you shouldn't use any other method to generate links in custom code. Generating a link is like early rendering. See https://www.lullabot.com/articles/early-rendering-a-lesson-in-debugging-drupal-8
Instead add the link as render element to the build array.
Like this examples which also demonstrates how you can build nested render elements, here an image as link title:
      $link_title = [
        '#theme' =&gt; 'image',
        '#uri' =&gt; $image,
        '#alt' =&gt; $label,
      ];
      $image_link = [
        '#type' =&gt; 'link',
        '#title' =&gt; $link_title,
        '#url' =&gt; Url::fromUri($link_href),
        '#options' =&gt; [
          'attributes' =&gt; ['class' =&gt; ['feed-image']],
        ],
      ];

      $build[$id]['image'] = $image_link;

Example from /core/modules/aggregator/src/FeedViewBuilder.php