Difference between new Operator and newInstance() Method in java || Part - 2

Veröffentlicht am: 26 November 2018
auf dem Kanal: VK Programming Villa
1,820
38

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


Auf dieser Seite können Sie das Online-Video Difference between new Operator and newInstance() Method in java || Part - 2 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer VK Programming Villa 26 November 2018 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 1,820 Mal angesehen und es wurde von 38 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!