Professional Documents
Culture Documents
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 Sunday, 12 November 2023, 5:39 PM
State Finished
Completed on Sunday, 12 November 2023, 5:44 PM
Time taken 5 mins 40 secs
Marks 4.00/5.00
Grade 80.00 out of 100.00
Feedback
Congratulations!!! You have passed by securing more than 80%
42763
42763
42763
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=685301&cmid=1214 1/6
11/14/23, 3:54 PM Test your understanding - static (copy): Attempt review
Question 1
Correct
//Line 1
}
Which of the following code can be included in Line 1?
}
42763
b.
public void display(){
System.out.println("Employee Name"+name);
c.
public void display(){
42763
}
d.
public static void display() {
System.out.println("Employee Name"+name);
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.
},
42763
System.out.println("Employee count "+employeeCount);
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=685301&cmid=1214 2/6
11/14/23, 3:54 PM Test your understanding - static (copy): Attempt review
Question 2
Correct
}
}
42763
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;
} 42763
[System.out.println("No of seats "+noOfSeats);]
42763
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=685301&cmid=1214 3/6
11/14/23, 3:54 PM Test your understanding - static (copy): Attempt review
Question 3
Partially correct
String productName;
static int count = 0;
productId = pid;
productName=name;
42763
count++;
System.out.println("Count is "+Product.count);
42763
System.out.println("Count is "+(1+p2.count));
}
Choose the options correctly so that the output will be
Count is 1
Count is 3
int productId;
String productName;
static int count = 0;
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=685301&cmid=1214 4/6
11/14/23, 3:54 PM Test your understanding - static (copy): Attempt review
productName=name;
count++;
[System.out.println("Count is "+Product.count);]
Product p2=new Product(102,"Nuts");
Product p3=new Product(103,"Nails");
[System.out.println("Count is "+Product.count);]
}
}
Choose the options correctly so that the output will be
42763
Count is 1
Count is 3
Question 4
Correct
static method
Can access static members only
The correct answer is: non static method → Can access both static and non static members, static method → Can access static members only
42763
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=685301&cmid=1214 5/6
11/14/23, 3:54 PM Test your understanding - static (copy): Attempt review
Question 5
Partially correct
For the below code, what are the valid ways to invoke display method in the main method.
}
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.
◄ Static
42763
Jump to...
Wrapper Scanner ►
42763
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=685301&cmid=1214 6/6