In this tutorial we’re going to look at very important Java another case of difference between new Operator and newInstance() Method according to the technical interview perspective and learn it with example in detail.
In previous tutorial, we covered about “new” operator, it can use to create an object if we know class name at the beginning and but if we don’t know class name at the beginning and we will get to know it dynamically at the run time from any file, or command line arguments or may be from database then we should use there newInstance() method which is present in class Class.
In this tutorial, we are going to learn, in the case of “new” Operator, based on our requirement, we can invoke any constructor either it is parameterized or non-parameterized constructor. But in the case of newInstance() method, it internally calls no-argument constructor. Hence to use newInstance() method compulsory corresponding class should contain no-argument constructor. Otherwise we will get Runtime Exception saying, InstantiationException.
#java #newOperator #newInstanceMethod #classClassObject #Constructor #SCJP #OCJP #Interview #Programming #Tutorials
Social Links: Don't hesitate to contact me if you have any further questions.
FACEBOOK: / cse.programming.assignments
GOOGLE+ : https://plus.google.com/u/0/114693282...
Quora: https://www.quora.com/profile/Vinay-K...
Related Videos: • OCJP-SCJP Exam / Java Interview Preparation
Gmail: vkprogrammingvilla.com
In questa pagina del sito puoi guardare il video online Difference between new Operator and newInstance() Method in java || Part - 2 della durata di ore minuti seconda in buona qualità , che l'utente ha caricato VK Programming Villa 26 novembre 2018, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,820 volte e gli è piaciuto 38 spettatori. Buona visione!