Question 1
Question text
Which members of a class can be accessed by other classes is determined by the ________________
Feedback
Question 2
Question text
Predict the Output of following Java Program.
class Test {
int x = 10;
public static void main(String[] args) {
System.out.println(x);
}
}
Feedback
Question 3
Question text
Identify the true statement(s).
Statement 1 : When no constructor is written in a class, the compiler creates a default constructor
Statement 2 : The default constructor will implicitly invoke the default / no-argument constructor of the super class
Statement 3 : If a class has a parametrized constructor alone, then the compiler will create the default constructor
Statement 4 : If a class has a parametrized constructor, it is mandatory to write a no-argument constructor
Feedback
Question 4
Question text
What does this() mean in constructor chaining concept?
Feedback
Question 5
Question text
Given:
public class ItemTest
{
private final int id;
public ItemTest(int id) {
this.id = id;
}
public void updateId(int newId) {
id = newId;
}
public static void main(String[] args) {
ItemTest fa = new ItemTest(42);
fa.updateId(69);
System.out.println(fa.id);
}
}
What is the result?
Feedback
Question 6
Question text
A JavaBeans component has the following field:
private boolean enabled;
Which two pairs of method declarations follow the JavaBeans standard for accessing this field? (Choose two.)
Feedback
When writing getters and setters, setters return type is void and getters return type is the corresponding data type. Naming convention is camelcase notation. For setters start with set followed by field name and for getters start with get followed by field name. For boolean return type, it should start with 'is' or 'are' followed by field name.
public boolean isEnabled(), public void setEnabled( boolean enabled )
public boolean getEnabled()
Question 7
Question text
package edu.ABC.model;
public class Account {
public static final float INTERTEST_RATE = 7.5;
}
Identify the correct options from the classes provided below.
Feedback
public class Loan {
public double getInterest() {
return INTEREST_RATE; \
}
}, import edu.ABC.model.Account ;
public class Loan {
public double getInterest() {
return Account.INTEREST_RATE;
}
}
Question 8
Question text
Identify which statement is true about construtors.
Feedback
Constructor can be overloaded
Comments
Post a Comment