The answer is "A".
However, there was a typo in the alternatives, it should contain TV Price:1100 Refrigerator Price:2100 instead of TV Price :110 Refrigerator Price :2100
A is correct
TV Price: 1100Refrigerator Price: 2100
class Product {
String name;
Integer price;
Product(String name, Integer price){
this.name = name;
this.price = price;
}
public void printVal() {System.out.print(name + " Price: "+ price);}
public void setPrice(int price) {this.price = price;}
public Integer getPrice() {return price;}
}
public class Test {
public static void main (String[] args) {
List<Product> li = Arrays.asList(new Product ("TV",1000), new Product ("Refrigerator",2000));
Consumer<Product> raise = e->e.setPrice(e.getPrice()+100);
li.forEach(raise);
li.stream().forEach(Product::printVal);
}}
upvoted 4 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
steefaand
5 months, 4 weeks agolnrdgst
2 years, 2 months agoOhayou
2 years, 4 months agoAVB22
2 years, 8 months ago