How to Test Java programming skills Online Quiz 10

Explanations of answers for Quiz 10

Lesson Details:
January 14, 2020

This course is brought to you by Appy Pie as part of our Academy series explanation of question 1 quiz 10 miscellaneous question abstract class always provide complete abstraction now friends this statement is partially true because abstract class can provide complete abstraction but a abstract class can also contain non abstract methods as well in other words we can say an abstract class is capable of provide partial abstraction and in fact the whole and sole purpose behind abstract class is to provide partial abstraction because we have something known as interfaces to provides complete abstraction as a result this statement is false because abstract class can also provide partial abstraction it will not provide complete abstraction everything so the correct option is the second option false let's proceed further explanation of question number two from quiz 10 miscellaneous questions and the question is object of an anonymous class can be created and the options are true or false now friends what is an anonymous class a anonymous class is a class with no name inference in order to create a new object foreign class we need the name of the class and as anonymous class has no name we won't be able to create a new object for the class now friends the whole and sole purpose behind anonymous class is to use it once whenever we require to make use of a class once we can go for the option of anonymous class as a result the statement is false hence the second option is the correct option let's also check the third question in this lecture itself and the question is static method of a class can access instance variable on the same class in fact this needs to be off not on its and typo in here so the static method of a class can access instance variable of the same class true or false and the correct option is false a static method can access only static variable from the class and if we try to access an instance variable there would be an compile time error hence the second option is the correct option the statement is false explanation of question for quiz 10 miscellaneous questions and the question is in order to achieve complete abstraction and Java we have to make use of abstract class interface abstract class or interface and the final option is neither abstract class nor interface now friends the fourth option is definitely not right because in order to achieve abstraction in the Java we have to make use of either abstract class or interface now if we read the question in here they have asked in order to achieve complete abstraction under Java now interface provides complete abstraction that's for sure and abstract class is also capable to provide partial abstraction in fact there could be a possibility as well that a person and defines a class as abstract but doesn't have any abstract method so even that is possible reference if we read the question once again in order to achieve complete abstraction and Java we can make use of and the correct option is abstract class or interface because even abstract class can provide complete abstraction and interface definite we provides and complete abstraction hence the third option is the correct option moving forward to the fifth question and the question has super keyword is used for and the options are the first option making a call to the constructor of a parent class the second option is access or invoke immediate parent class variable or method third option is access immediate parent class variable and the final option is invoke immediate parent class method reference the first option is definitely incorrect because super method is used to call the constructor of parent class not the super keyword hence the first option is definitely incorrect now if we would like to make a call to parent method or access and variable from a parent method with same name then we can definitely make use of super keyword now the whole and sole purpose of super keyword is to give a way by using which we can invoke the immediate parent class method or we can access the immediate parent class variable hence the second option is the correct option thank you for listening and stay tuned for more explanation explanation for question sex from quest and miscellaneous questions enough friends this particular question is pretty important and this is a part of multi-threading concept and a Java and the question is the joint method is used for and the options are making other thread to wait until the specified thread completes its execution the first option the second option is join joins the specified thread with the current thread the third option is to synchronize the threads in the fourth option and the final option is none of above now friends the correct option as making other thread to wait until the specified thread completes its execution the first option is the correct option in fact this statement is nothing but the whole and sole purpose of the join method join method will force the other threads to wait until the thread completes its execution enough friends that is a legit little typo in here for this word specified it's specified and there is a little type of a we'll fix this when we would be releasing and the quiz moving forward to question number 7 how we can create thread in Java now friends this is a very common question asked and interviews and asked in examination that what are the possible fees using which we can create and thread and the Java and let's check the options first the first option is by extending the thread class the second option is by implementing their enable interface the third option is by extending the thread class or by implementing the runnable interface and the final option is by extending the thread class and by implementing the runnable interface and the correct option is the third option because both of these ways can be used for creating a thread either by extending a thread class or by implementing a Renewable interface the fourth option is incorrect because we need only one of these options not both of them hence the third option is the correct option that either we may use extending the thread class option or we can easily implement a runnable interface and by implementing the methods inside the Renewable interface which is the run method we can create n thread under Java so the third option is the correct option thank you for listening and have a nice day explanation of question 8 quiz 10 miscellaneous questions and the question is through keyword can be used for throw an exception explicitly true or false not is an absolutely correct statement that a throw keyword can be used to throw an exception explicitly hence there is no doubt the first option is the correct option true the statement is true let's proceed further with the next question question number 9 and the question is what would be the output of the program and the program is pretty simple and if you notice in here there would be an compile time error why because in here if we check these two catch blocks the first catch block is based on exception class and whereas the second catch block is based on the arithmetic exception block now exception block is the parent class and capable of handling arithmetic exceptions as well hence making the second catch block as an unreachable code remember always remember this friends again this is a very popular question and interviews and in fact in examination and the question or the hint is that whenever there are multiple catch blocks a parent class cannot be first always the sequence would be a child class needs to be first and then only we can place the parent class because a parent class is capable of handling all the exception including the exception that could be handled by the child class and Java follows the rule of first-come first-serve paste so the exception would be called by the parent class and the catch block of the child exception would be an unreachable cold hence the correct option is the fourth option that that would be an compile time error so this is all about the quiz ten because the final question is not related to infant Java this question is related to the overall course and the question is did you like this course and F yes please consider rating this course and now friends this is again an important thing your rating and reviews on the course is a very important thing good reviews motivates us and most importantly reviews also help other user to make an decision whether they should whether they should take the course or not and taking a course it's like an investment to your career and investments needs to be in a correct and a good way hence your reviews can help thousands of people so to consider writing and reading this course and do check our other courses and consider them if you like our work.

Course content