PART 1: Multiple choice questions. (10 questions) 1. In Java classes can either
ID: 3909491 • Letter: P
Question
PART 1: Multiple choice questions. (10 questions) 1. In Java classes can either have States or Behavior, but never both a. True b. False Which of these class is superclass (Parent) of every class in Java? a) String class b) Object class c) Abstract class d) ArrayList class 2. 3. Below code defines a legal class public class A a. True b. False 4. What best describes the below lines of code Fraction f-new Fraction(1, 3): Upon the execution of this code f is an object that is created, however we still need to set its numerator and denominator explicitly in the Driver class. Fraction class will only have one constructor for now onwards. This class cannot have any additional constructors. ?f is instantiated using the Fraction class constructor that takes two integer a. b. c. d. Above syntax is wrong. You cannot create and object and set the fields simultaneously in one step 5. What is the output of the following program public class A t private int i private int j; public class Driver ( public static void main(String args t1) A obj1 new A); A obj2 new A): System.out.print obji. equats(obj2)): a. True b. FalseExplanation / Answer
1.
In java classes are either have states or behaviour but never both.
False
Since classes contain both states and behaviour.
2.
Object class of these class is superclass (Parent) of every class in Java
Option b
3.
public class A
{
}
It defines a legal class
True
4.
Code Fraction f = new Fraction(1, 3):
The above syntax is false.
You cannot create and object and set the fields simultaneously in one step.
Option d
5.
public class A {
private int i;
private int j;
}
class Main {
public static void main(String[] args) {
A obj1 = new A();
A obj2 = new A();
System.out.print(obj1.equals(obj2));
}
}
False
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.