Test Your Understanding - Classes and Objects (Copy) - Attempt Review
Test Your Understanding - Classes and Objects (Copy) - Attempt Review
Dashboard / App Dev / Stage - 1 / Java Programming / Classes and Objects, Packages
Quiz review
Started on Sunday, 12 November 2023, 4:20 PM
State Finished
Completed on Sunday, 12 November 2023, 4:31 PM
Time taken 10 mins 19 secs
Marks 7.67/8.00
Grade 95.83 out of 100.00
Feedback Congratulations!!! You have passed by securing more than 80%
Question 1
Correct
42763
___ and _____ are the access specifiers that can be applied to top level Class.
b. default
c. public
d. virtual
42763
Your answer is correct.
42763
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=684946&cmid=1206 1/9
11/14/23, 3:40 PM Test Your understanding - Classes and Objects (copy): Attempt review
Question 2
Partially correct
Analyze the below program and choose the appropriate code so that it produces the below output:
0
101
class Book {
42763
this.bookId = bookId;
}
public double getBookPrice() {
return bookPrice;
}
public void setBookPrice(double bookPrice) {
this.bookPrice = bookPrice;
}
42763
public class Test {
public static void main(String a[]) {
System.out.println(bobj.getBookPrice());
bobj.setBookId(101);
System.out.println(bobj.getBookId());
}
}
42763
Note : Same option can be used multiple times. Analyse and use the correct option
Analyze the below program and choose the appropriate code so that it produces the below output:
0
101
class Book {
private int bookId;
private double bookPrice;
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=684946&cmid=1206 2/9
11/14/23, 3:40 PM Test Your understanding - Classes and Objects (copy): Attempt review
return bookId;
}
}
public void setBookPrice(double bookPrice) {
this.bookPrice = bookPrice;
}
}
public class Test {
public static void main(String a[]) {
42763
Book bobj=new Book();
[System.out.println(bobj.getBookId());]
[bobj.setBookId(101);]
[System.out.println(bobj.getBookId());]
}
Note : Same option can be used multiple times. Analyse and use the correct option
42763
42763
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=684946&cmid=1206 3/9
11/14/23, 3:40 PM Test Your understanding - Classes and Objects (copy): Attempt review
Question 3
Correct
Choose the correct option so that the code runs without any compilation errors
{
if (salary > 0) {
salary = salary1;
}
42763
b. public class Employee {
if (salary > 0) {
salary = salary1;
}
}
salary = salary1;
}
}
}
salary = salary1;
}
public void setSalary(float salary1) {
}
}
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=684946&cmid=1206 4/9
11/14/23, 3:40 PM Test Your understanding - Classes and Objects (copy): Attempt review
The correct answer is:
public class Employee {
salary = salary1;
}
}
Question 4
Correct
class Sample{
}
public class Test{
System.out.println(obj.num);
System.out.println(obj.square(10));
42763
}
Select one:
a. Run time error
42763
Your answer is correct.
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=684946&cmid=1206 5/9
11/14/23, 3:40 PM Test Your understanding - Classes and Objects (copy): Attempt review
Question 5
Correct
Choose the appropriate access specifier for the attribute value so that it can be accessed from anywhere.
class Test
{
class Test
42763
{
[public] int value;
Question 6
Correct
Choose the appropriate return type for the getters and setters provided below.
42763
class Test
42763
The correct answer is:
Choose the appropriate return type for the getters and setters provided below.
class Test
{
private int value;
public [void] setValue(int value){//some code}
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=684946&cmid=1206 6/9
11/14/23, 3:40 PM Test Your understanding - Classes and Objects (copy): Attempt review
Question 7
Correct
class Test
{
public static void main(String a[])
{
}
42763
System.out.println(s.studentId);
Select one:
a. Any value
b. 1
c. 0
42763
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=684946&cmid=1206 7/9
11/14/23, 3:40 PM Test Your understanding - Classes and Objects (copy): Attempt review
Question 8
Correct
System.out.println("BookId:"+bobj.getId());
public class Book {
private int bookId;
} 42763
public double getBookPrice() {
return bookPrice;
}
}
42763
public static void main(String[] args) {
Book bobj=new Book();
bobj.setBookId(123);
bobj.setBookPrice(500);
System.out.println("BookId:"+bobj.getId());
System.out.println("BookPrice:"+bobj.getBookPrice());
}
}
42763
Analyze the above code and select the correct reason for the error.
Select one:
a. “+” symbol should not be used in System.out.println
https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=684946&cmid=1206 8/9