Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q1 Which comparison below is acceptable in Java syntax if the following declarat

ID: 3908692 • Letter: Q

Question


Q1 Which comparison below is acceptable in Java syntax if the following declarations are made?

CSC142Point p1 = new CSC142Point( 3, 4 );
CSC142Point p2 = new CSC142Point( 5, 6 );

  
1 p1.getX() > p2.getX()
  
2 p1.setX(5) == p2.setX(5)

  
3 p1 < p2
  
4 all of the above

  
5 none of the first 3 are acceptable syntax in Java

Q2 Which of the following things may an abstract class contain in addition to abstract methods?
  
1 method definitions with implementations

  
2 instance variable declarations

  
3 constructor definitions with implementations

  
4 class constants (final variables)

  
5 All of the above.

Q3 What is the difference between an abstract class and a concrete class?
  
1 An abstract class may NOT be extended.
  
2 An abstract class may NOT be instantiated.
  
3 All methods in an abstract class must be abstract.


4 A reference variable cannot have an abstract class as its static type.

  
5 All of the above.

Q4 Which of the following is true about a concrete class?
  
1 A concrete class may be extended.
  
2 A concrete class may be instantiated.
  
3 A concrete may NOT contain abstract methods.

  
4 All of the above.

  
5 None of the above.

Q5 Which of the following is true?

1 A class extends exactly one other class and may implement any number of interfaces.

2 A class may extend at most one concrete class, may extend any number of abstract classes, and may implement any number of interfaces.

3 A class may extend one concrete class and also one abstract class, and may implement any number of interfaces.

4 A class may extend exactly one other class, OR may implement any number of interfaces, but not both.

Explanation / Answer

Answer 1:

1 p1.getX() > p2.getX()

is acceptable Java syntax


================

Answer 2:
5 All of the above.

An abstract class can have all those mentioned options apart from abstract methods.

========
Answer 3:

2 An abstract class may NOT be instantiated.
=============
Answer 4:

4 All of the above.

=============
Answer 5:

1 A class extends exactly one other class and may implement any number of interfaces.

============

Please do rate the answer if helpful. Thank you