How to Test Java programming skills Online Quiz 07

Explanations of answers for Quiz 07

Lesson Details:
January 14, 2020

This course is brought to you by Appy Pie as part of our Academy series alright so here are a couple of more interesting question and let us check these questions real quick alright so the first question is which keyword can be used to prevent method over sliding the correct answer as final and this is kind of very simple question if we make use of final keyword overriding not accepted let us check the answer good job let's proceed further and check the next question what is the correct way of importing an entire package say the name of the packages world the correct answer is making use of the star wildcard character and if you check these options then the third option in here we are making use of the star Valgard character and the correct option in here as import world dot star semi colon that said let's check the answer good job let's proceed further and here is the next question constructors are used to what are the options initialize variables okay initialize a newly created object okay to allocate memory and capsulation alright so the correct option is the second option in order to initialize of a newly created object we always make use of constructors all right so let's proceed further here is the next question what is the correct way of calling the default constructor of superclass C the superclass is X and the subclass as Y alright so the way of calling the superclass is super easy we make use of super method so pretty simple the correct answer is the second option the super method we simply call the super method and the constructor of your superclass will be called right let's proceed further all right so the next question is which of these acts as a specifier can be used for a class if we want a class member can be accessed by a different class in the same package now this question is a little tricky because we might think that all right the correct answer is no modifier or we can think the correct answer is protected but the correct answer is all of the mentioned even public protected no modifier all of these three options and correct options if we choose any of these accesses specifier definitely we can access class member within the same package so the correct answer is the fourth option all of the mentioned and there might be some confusion in your mind what as access modifier or X as a specifier both are one and the same all right so let us check the answer real quick good job let's proceed further and check the next question and here is the next question methods and constructors can be overloaded definitely this is a true statement let me proceed further good job so here is the seventh question which operator is used to allocate memory for array variable in Java let me repeat this once again which operator is used to allocate memory for array variable in Java now in here there is a catch what is re array as nothing but object and definitely in order to allocate memory for a new object we make use of the new keyword as a result the first option is the correct option which operator is used to allocate memory for array variable in Java definitely new alright so let us check the answer good job so these were the first seven question from the squares and the quick explanation of these questions all right so this was it for this video and I will you in the next video with a new explanation and a new question catch you in the next video hey there here is a jet under the program and we need to determine the output for this program in here we have a class by the name of quiz and inside this particular quiz class we have the main method right alright so inside the main method first of all we have created an object of class of I type and let us check these two classes these classes are class X and class Y and in here first of all inside class X we have this indentity and I and inside this class XP also have a display method which is simply displaying the value of I which is okay all right moving forward we have a class Y which extends class X right all right so this seems to be good enough and inside this class wire we have the variable chain okay no problem and moving forward we also have a yet another display method inside the class wire which is displaying the value of J all right so things have sorted out we are able to understand how things would be in here the display version of class wire would be accessed if we will create an object of wire type all right so moving forward we will check the class quiz now so inside the class squares we have an object of wire type all right and then we are initializing the value of I using the value 5 so now the value of I inside the object obj would be 5 which is okay then we are also initializing the value of J inside the object obj with value 8 then finally we are calling the display method alright so there is a catch in this program always remember the priority of the local entity would be always more than the global entity so in here the local as the display method which is inside the class wire right so this particular copy of the method would be executed which is highlighted right now on the screen and as the value of j is 8 the output of this program would be 8 and I'm pretty sure that the output is 8 here people so this was all about the explanation of this program this is quite simple program but an interesting program as well so hope you guys enjoyed this lecture and I will catch you in the next video hey there here is yet another program in front of us and let us check what would be the output for the same alright so in here we have a simple class by the name of quiz and inside the squares class we have the main method right and there is simply a loop a for loop and we are simply declaring a variable I and then there is a for loop now there is a catch in here the catch is pretty simple inside this for loop we are making use of a if condition then we also have the continuous statement right now friends the purpose of continue statement is to skip the remaining statements which are there inside the loop right and after this continue statement there is no statement in fact so the usage of these two statements at line number 5 & 6 is when I think the impact would be simply nothing as a result it's simply a try loop and there won't be any effect on the output of the program because of this loop but definitely there could be effect on the variable I and as that would be it duration and times in this loop and the condition is I is less than 10 the final value of I would be 10 in fact because when the value of I would be 10 the condition will be false and finally we will be printing this line of code over here simply printing the value of I the output is simple the output is 10 for this program hope you guys got the point and I will catch you with a new explanation in the next video alright so here is the final question from the squares the question is in Java can only test for equality well as dash can evaluate any type of boolean expression now the correct option is the second option now switch can only test equivalent whereas if condition can evaluate a boolean expression so the second option is the correct option good job.

loader
Course content