а Will the following code from a file called "student.java" compile? If not, then why? public class Student { private int id; private String name; public Student(int id, String name) { this.id = id; this.name name; } = = = = public void setId(int i) {id = i;} public void setName(String n) {name = n; } } public int getId() {return id;} public String getName() {return name;} } No, the whitespace around the getter and setter methods is incorrect. No, the class name must match the file name. o No, the "this" keyword is missing in the getter and setter methods. Yes, it will compile. o No, there is a missing }.
What is wrong with the following code? public class Main { public boolean checkOdd(int a ) { return a % 2 1; } public static void main(Strin g[] args) { for(int i=0; i<10; i++) { if(checkOdd(i)) { System.out.printl n(i+" is odd!"); } } } o There is an incorrect number of opening and/or closing brackets. The checkOdd method is not called properly. O A variable is used that has not been declared. o A semicolon is missing.
If you have a private method called calculateTotal() in ReceiptClass, how would you call this method on an object of ReceiptClass called myReceipt? o calculateTotal(); o myReceiptClass.calculateTotal(); o myReceipt cannot call the calculateTotal() method. Calling this method will result in a compiler error o myReceipt cannot call the calculateTotal() method. Calling this method will result in a runtime error. o myReceipt.calculateTotal();
а Will the following code from a file called "student.java" compile? If not, then why? public class Student { private in
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
а Will the following code from a file called "student.java" compile? If not, then why? public class Student { private in
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!