How to check if customer is logged in or not in magento 2?

In Magento 2 we can check Customer is logged in or not by below way,
Using Block file, Pass Magento\Framework\App\Http\Context as a dependency to construct method.

Call getLogin function in template file,

Using ObjectManager, Never use Objectmanager directly in real code in magento 2. Here I have show just demonstrate using Objectmanager. Using Objectmanager directly create performance issue for the site.