DevOps / Apache Groovy Interview questions
Define the safe navigation operator in Groovy?
The safe navigation operator, written ?., lets you call a method or access a property on an object that might be null without throwing a NullPointerException - if the object is null, the whole expression short-circuits and simply evaluates to null instead of throwing.
It's especially useful for chained property access, like user?.address?.city, where any link in the chain could be null; without it, each step would need an explicit null check to avoid an exception.
It only guards against the object immediately to its left being null - a longer chain still needs ?. applied at each link where a null is genuinely possible, since the check doesn't automatically extend past where it's applied.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
