What is the result?

Correct Answer for the Question – What is the result? is given below Given:11. public class Test {12. public static void main(String [] args) {13. int x = 5;14. boolean b1 = true;15. boolean b2 = false;16.17. if ((x == 4) && !b2 )18. System.out.print(“1 “);19. System.out.print(“2 “);20. if ((b2 = true) && b1 )21. System.out.print(“3 … Read more

Which two code fragments, inserted independently at line 13, will compile?

Correct Answer for the Question – Which two code fragments, inserted independently at line 13, will compile? is given below Given:class Employee {String name; double baseSalary;Employee(String name, double baseSalary) {this.name = name;this.baseSalary = baseSalary;}}09. public class SalesPerson extends Employee {10. double commission;11.12. public SalesPerson(String name, double baseSalary, double commission) {13. // insert code here14. }15. }Which … Read more

Which two statements are true about the result if the default locale is Locale.US?

Correct Answer for the Question – Which two statements are true about the result if the default locale is Locale.US? is given below Given:NumberFormat nf = NumberFormat.getInstance();nf.setMaximumFractionDigits(4);nf.setMinimumFractionDigits(2);String a = nf.format(3.1415926);String b = nf.format(2);Which two statements are true about the result if the default locale is Locale.US? (Choose two.) The value of b is 2. The value … Read more

Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class?

Correct Answer for the Question – Which three, taken independently, will allow the developer to use the Paper class while compiling the Book class? is given below A developer is creating a class Book, that needs to access class Paper. The Paper class is deployed in a JAR named myLib.jar. Which three, taken independently, will allow … Read more

Which four code fragments, inserted independently at line 7, will compile?

Correct Answer for the Question – Which four code fragments, inserted independently at line 7, will compile? is given below Given:01. public class Hi {02. void m1() { }03. protected void() m2 { }04. }05.06. class Lois extends Hi {07. // insert code here08. }Which four code fragments, inserted independently at line 7, will compile? (Choose … Read more

Which four statements are true?

Correct Answer for the Question – Which four statements are true? is given below Which four statements are true? (Choose four.) Has-a relationships should never be encapsulated. Has-a relationships should be implemented using inheritance. Has-a relationships can be implemented using instance variables. Is-a relationships can be implemented using the extends keyword. Is-a relationships can be implemented … Read more

What is the output if the main() method is run?

Correct Answer for the Question – What is the output if the main() method is run? is given below What is the output if the main() method is run?public class Starter extends Thread {private int x = 2;public static void main(String[] args) throws Exception {new Starter().makeItSo();}public Starter(){x = 5;start();}public void makeItSo() throws Exception {join();x = x … Read more