Test Your Understanding - Static (Copy) - Attempt Review
Test Your Understanding - Static (Copy) - Attempt Review
Dashboard / App Dev / Stage - 1 / Java Programming / Classes and Objects, Packages
Quiz review
Started on Tuesday, 12 September 2023, 9:11 PM
State Finished
Completed on Tuesday, 12 September 2023, 9:21 PM
Time taken 9 mins 41 secs
Marks 4.33/5.00
Grade 86.67 out of 100.00
Feedback
Congratulations!!! You have passed by securing more than 80%
Question 1
37547
Correct
non static method Can access both static and non static members
static method
Can access static members only
37547
Your answer is correct.
The correct answer is: non static method → Can access both static and non static members, static method → Can access static members only
37547
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=67961&cmid=1214#question-67961-4 1/5
9/12/23, 9:22 PM Test your understanding - static (copy): Attempt review
Question 2
Correct
String productName;
static int count = 0;
37547
count++;
System.out.println("Count is "+Product.count);
}
37547
System.out.println("Count is "+Product.count);
Count is 1
Count is 3
int productId;
String productName;
productId = pid;
productName=name;
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=67961&cmid=1214#question-67961-4 2/5
9/12/23, 9:22 PM Test your understanding - static (copy): Attempt review
count++;
}
37547
Count is 3
Question 3
Correct
37547
Non static members cannot be accessed from static methods. If we want to access non static members from a static method it is
possible by creating an object. Hence, only "noOfSeats" can be accessed, not "flightId".
int flightId;
static int noOfSeats;
}
}
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=67961&cmid=1214#question-67961-4 3/5
9/12/23, 9:22 PM Test your understanding - static (copy): Attempt review
Question 4
Partially correct
//Line 1
}
Which of the following code can be included in Line 1?
c.
public static void display() {
System.out.println("Employee Name"+name);
37547
}
d.
public void display(){
From a static method, we can access only static members. Non static members cannot be accessed from static methods.
However, from a non static method, we can access both static and non static members.
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=67961&cmid=1214#question-67961-4 4/5
9/12/23, 9:22 PM Test your understanding - static (copy): Attempt review
Question 5
Correct
For the below code, what are the valid ways to invoke display method in the main method.
public class Test {
public static void display(){
}
}
public class Main {
public static void main(String a[]){
//Invoke the display method
}
}
c. display();
Static method can be invoked either by using the object instance or using the class name.
The correct answers are: Test.display();, new Test().display();
◄ Static 37547
Jump to...
Wrapper Scanner ►
37547
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=67961&cmid=1214#question-67961-4 5/5