0% found this document useful (0 votes)
16 views

Java-all quizes

sdfghdfrgthy

Uploaded by

lokeshballanki44
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Java-all quizes

sdfghdfrgthy

Uploaded by

lokeshballanki44
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 95

2/19/24, 8:06 PM Post-Quiz - Regular Expression: Attempt review


 Dashboard / My courses / Java / Regular Expression / Post-Quiz - Regular Expression

Quiz review
Started on Sunday, 28 January 2024, 7:43 PM
State Finished
Completed on Sunday, 28 January 2024, 7:47 PM
Time taken 4 mins 14 secs
Marks 10.00/10.00
Grade 100.00 out of 100.00

Question 1
Correct

Mark 1.00 out of 1.00

The first name of a person should contain only alphabets and space.

44953
Which of the following regular expression will match the requirement?

Select one:
a. [a-zA-Z ]+

b. [a-zA-Z ]

c. [\\s]+

d. [\\s]

Your answer is correct.

The correct answer is: [a-zA-Z ]+


44953
Question 2
Correct

Mark 1.00 out of 1.00

Which of the following text when matched with the regular expression “[a-zA-Z&&[^aeiou]]+” will return true?

Select one or more:


a. Good
44953
b. cry

c. My

d. must

Your answer is correct.

The correct answers are: My, cry

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121712&cmid=5255 1/4
2/19/24, 8:06 PM Post-Quiz - Regular Expression: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

00means X occurs zero or more times

Select one:
True 

False

The correct answer is 'True'.

Question 4
Correct

Mark 1.00 out of 1.00

44953
What is the regular expression to match a whitespace character in a string?

Select one:
\s
\d
\S
\w

The correct answer is: \s

Question 5
Correct
44953
Mark 1.00 out of 1.00

Consider the below statements.

Statement 1 : Matcher class interprets the pattern in a String

Statement 2 : Matcher class matches the regular expression against the text provided
Which of the following is true?

Select one:
a. Both Statement 1 and 2 are correct 44953
b. Statement 2 alone is correct.

c. Both Statement 1 and 2 are incorrect.

d.
Statement 1 alone is correct.

Your answer is correct.


The correct answer is: Both Statement 1 and 2 are correct

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121712&cmid=5255 2/4
2/19/24, 8:06 PM Post-Quiz - Regular Expression: Attempt review

Question 6
Correct

Mark 1.00 out of 1.00

What is the regular expression to match a digit (0-9) in a string?

Select one:
[0-9]
[A-Z]
[a-z]
[a-zA-Z]

The correct answer is: [0-9]

Question 7
Correct

Mark 1.00 out of 1.00

44953
Predict the output of the below code :

import java.util.regex.*;

public class TestRegEx{

public static void main(String args[]) {

Pattern p = Pattern.compile(".ech");
Matcher m = p.matcher("tech");
boolean b = m.matches();
System.out.println(b);

}
}
44953
Select one:
a. compile time error

b. 
true

c. false

d. Runtime Error

Your answer is correct.

The correct answer is: true


44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121712&cmid=5255 3/4
2/19/24, 8:06 PM Post-Quiz - Regular Expression: Attempt review

Question 8
Correct

Mark 1.00 out of 1.00

\B means ‘A word boundary’

Select one:
True

False 

The correct answer is 'False'.

Question 9
Correct

Mark 1.00 out of 1.00

44953
What is the regular expression to match any email address in a string?

Select one:
[A-Za-z0-9.%+-]+@[A-Za-z0-9.-]+
[A-Za-z0-9.%+-]+@[A-Za-z0-9.-]+.[A-Z|a-z]{2,}
[A-Za-z0-9.%+-]+
[A-Za-z0-9.%+-]+.[A-Z|a-z]{2,}

The correct answer is: [A-Za-z0-9.%+-]+@[A-Za-z0-9.-]+.[A-Z|a-z]{2,}

Question 10
Correct
44953
Mark 1.00 out of 1.00

What is the regular expression to match any date in the format "yyyy-mm-dd" in a string?

Select one:
\d{2}-\d{2}-\d{4}
\d{2}/\d{2}/\d{4}
\d{4}-\d{2}-\d{2}
\d{4}/\d{2}/\d{2}

The correct answer is: \d{4}-\d{2}-\d{2}


44953

◄ Password Validator

Jump to...

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121712&cmid=5255 4/4
2/19/24, 8:05 PM Pre-Quiz - Regular expression: Attempt review


 Dashboard / My courses / Java / Regular Expression / Pre-Quiz - Regular expression

Quiz review
Started on Sunday, 28 January 2024, 7:37 PM
State Finished
Completed on Sunday, 28 January 2024, 7:38 PM
Time taken 52 secs
Marks 4.00/4.00
Grade 100.00 out of 100.00

Question 1
Correct

Mark 1.00 out of 1.00

Observe the below code snippet

44953
String name="Sudha learns Oracle";

System.out.println(name.substring(7,12));
What is the output of the above code?

Select one:
a. 
earns

b. learn

44953
c. learns

Your answer is correct.

The correct answer is: earns

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121608&cmid=5245 1/3
2/19/24, 8:05 PM Pre-Quiz - Regular expression: Attempt review

Question 2
Correct

Mark 1.00 out of 1.00

Predict the output of the below code :

String emailId="john#global.com";
System.out.println(emailId.indexOf('@'));

Select one:
a. 0

b. Any negative integer

c. -1

d. 1

Your answer is correct.


The correct answer is: -1
44953
Question 3
Correct

Mark 1.00 out of 1.00

What can be the parameters for the indexOf method in String class?

44953
Select one or more:
a. double

b. float

c. String

d. int

Your answer is correct.


The correct answers are: String, int

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121608&cmid=5245 2/3
2/19/24, 8:05 PM Pre-Quiz - Regular expression: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

Observe the below code :

String course="Java Programming";

char c=course.charAt(16);
System.out.println(c);

What will be the output for the above code snippet?

Select one:
a.
Compilation error

b. g

c.
44953
ArrayIndexOutOfBoundsException

d. 
StringIndexOutOfBoundsException

Your answer is correct.

The correct answer is: StringIndexOutOfBoundsException

◄ Post-Quiz Arrays and Strings

Jump to...
44953
Regular Expression-Intro ►

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121608&cmid=5245 3/3
2/19/24, 8:05 PM Post-Quiz Arrays and Strings: Attempt review


 Dashboard / My courses / Java / Arrays and Strings / Post-Quiz Arrays and Strings

Quiz review
Started on Sunday, 28 January 2024, 7:33 PM
State Finished
Completed on Sunday, 28 January 2024, 7:37 PM
Time taken 3 mins 41 secs
Marks 11.00/11.00
Grade 100.00 out of 100.00
Feedback Congratulations!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

String name="teknoturf"; 44953


String cname="teknoturf";
String compname=new String("teknoturf");
1.if(name==cname)

2.if(name.equals(cname))
3.if(name==compname)
4.if(name.equals(compname))
Identify the output.

Select one: 44953


a.
Line 1,3 will return true.

b. Line 1,2,4 will return true.

c.
Line 3,4 will return true.

d. Line 1,3,4 will return true.

44953
Your answer is correct.
The correct answer is: Line 1,2,4 will return true.

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121538&cmid=5243 1/6
2/19/24, 8:05 PM Post-Quiz Arrays and Strings: Attempt review

Question 2
Correct

Mark 1.00 out of 1.00

class ArrayTest {

public static void main(String args[]) {


int[] primes = new int[10];

primes[0] = "a";

System.out.println(primes[0]);
}

What will be the result of compiling and executing the above code?

Select one:

44953
a.
Runtime exception

b. compile time error

c.
ArrayStoreException

d. a

Your answer is correct.


The correct answer is: compile time error

Question 3
Correct
44953
Mark 1.00 out of 1.00

StringBuilder is less efficient and slower than StringBuffer. State true or false.

Select one:
True

False 

The correct answer is 'False'. 44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121538&cmid=5243 2/6
2/19/24, 8:05 PM Post-Quiz Arrays and Strings: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

In which of the following packages can you find String class?

Select one:
a. 
lang

b.
none of the options

c. io

d.
util

Your answer is correct.


The correct answer is:
lang 44953
Question 5
Correct

Mark 1.00 out of 1.00

class TestArray {

public static void main(String args[]) {

44953
int arr_sample[] = new int[2];

System.out.println(arr_sample[0]);
}

What will be the result of compiling and executing the above code?

Select one:
a. The program compiles and prints 0 when executed.

b.
The program compiles and runs but the results are not predictable because of un-initialized memory being read.

44953
c. The program does not compile because arr_sample[0] is being read before being initialized.

d.
The program generates a runtime exception because arr_sample[0] is being read before being initialized.

e. The program compiles and prints 1 when executed.

Your answer is correct.

The correct answer is: The program compiles and prints 0 when executed.

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121538&cmid=5243 3/6
2/19/24, 8:05 PM Post-Quiz Arrays and Strings: Attempt review

Question 6
Correct

Mark 1.00 out of 1.00

StringBuffer is used to create ______________.

Select one:
a.
an immutable String

b. a mutable String

Your answer is correct.


The correct answer is: a mutable String

Question 7

44953
Correct

Mark 1.00 out of 1.00

String Objects are mutable. State true or false.

Select one:
True

False 

The correct answer is 'False'.

Question 8
44953
Correct

Mark 1.00 out of 1.00

List the correct ways of declaring an Array.

Select one or more:


a. 
int studentId[ ];

b. int studentId[10]; 44953


c.
String name[]=new String(10);

d. String [ ] name [ ];

e. 
int [ ]studentId;

Your answer is correct.


The correct answers are:
int [ ]studentId;,
int studentId[ ];, String [ ] name [ ];

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121538&cmid=5243 4/6
2/19/24, 8:05 PM Post-Quiz Arrays and Strings: Attempt review

Question 9
Correct

Mark 1.00 out of 1.00

What is the output of this program?

class Output {

public static void main(String args[]) {

int a1[] = new int[10];

int a2[] = {1, 2, 3, 4, 5};

System.out.println(a1.length + " " + a2.length);

Select one:
a. 
10 5

b.

c.
05
44953
0 10

d. 5 10

Your answer is correct.


The correct answer is: 10 5

Question 10
Correct

Mark 1.00 out of 1.00 44953


State True or False.

Advanced for loop is better as it is less error prone as we don't need to deal with index.

Select one:
True 

False

The correct answer is 'True'.


44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121538&cmid=5243 5/6
2/19/24, 8:05 PM Post-Quiz Arrays and Strings: Attempt review

Question 11
Correct

Mark 1.00 out of 1.00

Given a one-dimensional array arr, what is the correct way of getting the number of elements in arr?

Select one:
a.
arr.length-1

b.
arr.length()

c.
arr.length()-1

d. arr.length

Your answer is correct.

44953
The correct answer is: arr.length

◄ Swap and Reverse

Jump to...

Pre-Quiz - Regular expression ►

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121538&cmid=5243 6/6
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review


 Dashboard / My courses / Java / Arrays and Strings / Test Your Understanding - Arrays and Strings

Quiz review
Started on Sunday, 28 January 2024, 7:20 PM
State Finished
Completed on Sunday, 28 January 2024, 7:32 PM
Time taken 11 mins 59 secs
Marks 20.67/21.00
Grade 98.41 out of 100.00
Feedback Congratulations!!! You have passed by securing more than 80%

44953

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 1/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 1
Correct

Mark 1.00 out of 1.00

What will be the content of array variable table after executing the following code?

public class Trial


{

public static void main(String[] args)

{
int []table[]=new int[5][5];

for(int i = 0; i < 3; i++)


{

for(int j = 0; j < 3; j++)

44953
if(j == i)

table[i][j] = 1;

System.out.print(table[i][j]);
}

else

table[i][j] = 0;

System.out.print(table[i][j]);
}

}
44953
System.out.println("\n");

}
}

Select one:
a. 
100
010

001
44953
b.
Compilation error

c.
100
110
111

d.
000
000

000

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 2/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

"table" is a 2 dimensional array with 5 rows and 5 columns. It is iterated from 0 through 3 and during each iteration j==i (iteration variables) is
checked. When j==i evaluates to true, the index is assigned the value "1" and printed. Else, assigned "0'" and printed.
The correct answer is:
100
010
001

Question 2
Correct

Mark 1.00 out of 1.00

String s1 = null;  is the valid declaration of a String.

44953
Your answer is correct.
The correct answer is:

[ String s1 = null;] is the valid declaration of a String.

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 3/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

Predict the output

class String_demo

public static void main(String args[])

{
int ascii[] = { 65, 66, 67, 68};

String s = new String(ascii, 1, 3);

System.out.println(s);

44953
Select one:
a. CDA

b. ABC

c. ABCD

d. BCD

44953
An integer array is initialized with values 65, 66, 67 and 68. Its reference is "ascii". A new string object is initialized with this reference
such that the elements from index 1 through 3 alone gets copied as "characters". This object is referred by "s". Printing this object will
output BCD which are the char-equivalents of 66, 67 and 68.
The correct answer is: BCD

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 4/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

Fill in appropriately.

String st1 = new String("JAVA");

String st2 = new String("JAVA");


String st3="JAVA"

3  objects, 2  in heap memory and 1  in string pool

Note : In heap memory does not include String pool, though pool is inside heap.

The "new" keyword allows memory for storing String to be allocated in the "heap" . Otherwise, memory is allocated in string pool.
The correct answer is:

44953
Fill in appropriately.

String st1 = new String("JAVA");

String st2 = new String("JAVA");

String st3="JAVA"

[3] objects, [2] in heap memory and [1] in string pool

Note : In heap memory does not include String pool, though pool is inside heap.

Question 5
Correct

44953
Mark 1.00 out of 1.00

Given a one dimensional array arr, what is the correct way of getting the number of elements in arr is arr.length 

Your answer is correct. 44953


The correct answer is:

Given a one dimensional array arr, what is the correct way of getting the number of elements in arr is [arr.length]

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 5/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 6
Correct

Mark 1.00 out of 1.00

Predict the output

class String_demo

public static void main(String args[])

char chars[] = {'a', 'b', 'c'};

String s = new String(chars);

System.out.println(s);

Select one:
a. b
44953
b. c

c. abc

d. a

A character array is initialized with 'a', 'b' and 'c' and the array reference is chars. Printing this reference will output abc.

A "new" string object is initialized with this reference and this object is referred by "s". Printing this reference will output abc.
The correct answer is: abc
44953
Question 7
Correct

Mark 1.00 out of 1.00

_______________ is used to allocate memory to array variable in Java

Select one:
a. alloc

b. new

c. calloc
44953
d. malloc

Your answer is correct.


The correct answer is:
new

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 6/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 8
Correct

Mark 1.00 out of 1.00

__________________ is the string contained in s after following lines of code?

StringBuffer s = new StringBuffer(“Hello”);

s.deleteCharAt(0);

Select one:
a. ello

b. hell

c. llo

d. Hel

Your answer is correct.


The correct answer is:
44953
ello

Question 9
Correct

Mark 1.00 out of 1.00

Determine the output: (MCQ)


public class Test

{
44953
public static void main(String[] args)

int[] x = new int[3];

System.out.println("x[0] is " + x[0]);

Select one:
44953
a. The program has a runtime error because the array elements are not initialized.

b. The program has a compile error because the size of the array wasn't specified when declaring the array.

c. The program has a runtime error because the array element x[0] is not defined.

d. The program runs fine and displays x[0] is 0.

The "new" keyword allows memory for storing integer elements in an array to be created in the "heap" and the memory is initialized with "default of integer"
which is 0.
The correct answer is: The program runs fine and displays x[0] is 0.

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 7/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 10
Correct

Mark 1.00 out of 1.00

Determine the output

public class Trial

public static void main(String[] args)

int arr[4]={};

System.out.print(arr[0]);

}
}

44953
Select one:
a. Runtime error

b. 0

c. Garbage error

d. Compile time error

int arr[4] is syntactically wrong


The correct answer is: Compile time error

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 8/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 11
Correct

Mark 1.00 out of 1.00

Determine the output:

class Evaluate

public static void main(String args[])

int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};

int n = 6;

n = arr[arr[n] / 2];

System.out.println(arr[n] / 2);

44953
}

Select one:
a. 6

b. 3

c. 1

d. 0

arr is an integer array that is initialized with 10 values.

44953
When n is initialized with value 6, n = arr[arr[n] / 2] evaluates to n = 3. Now, printing arr[n] / 2 will output 1.

The correct answer is: 1

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 9/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 12
Correct

Mark 1.00 out of 1.00

Determine the output

class array_output

public static void main(String args[])

char array_variable [] = new char[10];

for (int i = 0; i < 10; ++i)

array_variable[i] = 'i';

System.out.print(array_variable[i] + "");

44953
}

Select one:
a. i j k l m n o p q r

b. 1 2 3 4 5 6 7 8 9 10

c. 0 1 2 3 4 5 6 7 8 9 10

d. i i i i i i i i i i

44953
array_variable is a character array that can hold 10 characters. The for loop gets iterated for 10 times. During each iteration, the array index is assigned with
the character "i" and printed alongside. Hence the output "iiiiiiiiii".

The correct answer is: i i i i i i i i i i

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 10/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 13
Correct

Mark 1.00 out of 1.00

Determine the output:


public class Test

public static void main(String[] args)

int[] x = {1, 2, 3, 4};

int[] y = x;

x = new int[2];

for(int i = 0; i < x.length; i++)

System.out.print(y[i] + " ");

44953
}

Select one:
a. 0 0 0 0

b. 0 0

c. 1 2 3 4

d. 1 2

44953
Array x is initialized with 4 values and this means reference "x" contains the starting address of the array. This address is copied to the
array reference "y". This mean the 4 values can now be accessed with "y" as well. Then the reference x is assigned with a new array's
starting address whose length is 2. Hence the iteration outputs 1 2
The correct answer is: 1 2

Question 14
Correct

Mark 1.00 out of 1.00

44953
+ operator can be used to concatenate two or more String objects in java. State true or false.

Select one:
True 

False

The correct answer is 'True'.

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 11/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 15
Correct

Mark 1.00 out of 1.00

________________ is used to find string length.

Select one:
a. length()

b. size()

c. len

d. length

Your answer is correct.

The correct answer is:

44953
length()

Question 16
Correct

Mark 1.00 out of 1.00

What will s2 contain after following lines of code?

String s1 = “one”;
String s2 = s1.concat(“two”);

44953
Select one:
a. onetwo

b. one

c. twoone

d. two

44953
The string "two" referred by s2 is "concatenated to" the string "one" referred by s1.

The correct answer is: onetwo

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 12/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 17
Partially correct

Mark 0.67 out of 1.00

What is special about string objects as compared to objects of other derived types?

Select one or more:


a. You can concatenate two string objects using ‘+’

b. Java provides string constant pool to store the string objects

c. You can create string objects without or without using new operator

Your answer is partially correct.

You have correctly selected 2.


The correct answers are: You can concatenate two string objects using ‘+’, You can create string objects without or without using new operator, Java

44953
provides string constant pool to store the string objects

Question 18
Correct

Mark 1.00 out of 1.00

Column size is mandatory to create an array in java. State true or false

Select one:
True

False 

The correct answer is 'False'.


44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 13/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 19
Correct

Mark 1.00 out of 1.00

class Output
{

public static void main(String args[])


{

int a1[] = new int[10];


int a2[] = {1, 2, 3, 4, 5};

System.out.println(a1.length + " " + a2.length);


}

44953
Select one:
a. 0 5

b. 10 5

c. 0 10

d. 5 10

Array a1 is created so as to contain 10 integer elements. Hence, the length is 10.


Array a2 is initialized with 5 values. . Hence, the length is 5.
The correct answer is: 10 5

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 14/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 20
Correct

Mark 1.00 out of 1.00

Given:
1. public class MyLogger {
2. private StringBuilder logger = new StringBuuilder();
3. public void log(String message, String user) {
4. logger.append(message);
5. logger.append(user);
6. }
7. }
The programmer must guarantee that a single MyLogger object works properly for a multi-threaded system.
How must this code be changed to be thread-safe?

Select one:
a. No change is necessary, the current MyLogger code is already thread-safe.

44953
b. Replace StringBuilder with just a String object and use the string concatenation (+=) within the log method.

c. Replace StringBuilder with StringBuffer

d. Synchronize the log method

StringBuffer is synchronized and therefore thread-safe. StringBuilder is compatible with StringBuffer API but with no guarantee of
synchronization. Because it’s not a thread-safe implementation, it is faster and it is recommended to be used only in places where
there’s no need for thread safety.
The correct answer is: Replace StringBuilder with StringBuffer

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 15/16
2/19/24, 8:05 PM Test Your Understanding - Arrays and Strings: Attempt review

Question 21
Correct

Mark 1.00 out of 1.00

Determine the output:


public class A

{
public static void main(String argv[])

{
int ary[]=new int[]{1,2,3};

System.out.println(ary[1]);
}

44953
Select one:
a. 1

b. Compilation Error:incorrect syntax

c. 2

The array ary is initialized with 3 elements and the element at the first index is 2.
The correct answer is: 2

◄ String
44953
Jump to...

Arrays and Strings - Demo ►

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121301&cmid=5221 16/16
2/19/24, 8:04 PM Pre-Quiz Arrays and Strings: Attempt review


 Dashboard / My courses / Java / Arrays and Strings / Pre-Quiz Arrays and Strings

Quiz review
Started on Sunday, 28 January 2024, 7:15 PM
State Finished
Completed on Sunday, 28 January 2024, 7:19 PM
Time taken 4 mins 6 secs
Marks 8.00/8.00
Grade 100.00 out of 100.00
Feedback Congratulations!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

Given:
public class ItemTest
44953
{
private final int id;
public ItemTest(int id) {
this.id = id;
}
public void updateId(int newId) {
id = newId;
}
public static void main(String[] args) {

44953
ItemTest fa = new ItemTest(42);
fa.updateId(69);
System.out.println(fa.id);
}
}
What is the result?

Select one:
a. CompileTime Error

b.
Runtime Error

c.
69 44953
Your answer is correct.

The correct answer is: CompileTime Error

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121202&cmid=5214 1/6
2/19/24, 8:04 PM Pre-Quiz Arrays and Strings: Attempt review

Question 2
Correct

Mark 1.00 out of 1.00

Identify which statement is true about construtors.

Select one:
a. 
Constructor can be overloaded

b.
Constructor will be invoked explicitly like other methods

c.
Constructor should have same name as class name, but not case sensitive

d. Constructor of a class should not have a return type, which means the return type is void

Your answer is correct.

The correct answer is:


Constructor can be overloaded 44953
Question 3
Correct

Mark 1.00 out of 1.00

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.)

Select one or more: 44953


a. public boolean setEnabled( boolean enabled )

public boolean getEnabled()

b. public void setEnabled( boolean enabled )

public boolean isEnabled()

c. public void setEnabled( boolean enabled )

public void isEnabled()

d. public void setEnabled( boolean enabled )

public boolean getEnabled()


44953
Your answer is correct.
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.
The correct answers are: public void setEnabled( boolean enabled )
public boolean isEnabled(), public void setEnabled( boolean enabled )
public boolean getEnabled()

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121202&cmid=5214 2/6
2/19/24, 8:04 PM Pre-Quiz Arrays and Strings: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

What does this() mean in constructor chaining concept?

Select one:
a.
Used for calling the current object of the parent class.

b. 
Used for calling the no argument constructor of the same class.

c. Used for calling the parameterized constructor of the parent class.

d.
Used for calling the current object of the same class.

Your answer is correct.

44953
The correct answer is: Used for calling the no argument constructor of the same class.

Question 5
Correct

Mark 1.00 out of 1.00

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

44953
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

Select one:
a. 1, 2 and 4

b.
1, 2 and 3

c.
2 and 3

d. 
1 and 2

Your answer is correct.


44953
The correct answer is: 1 and 2

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121202&cmid=5214 3/6
2/19/24, 8:04 PM Pre-Quiz Arrays and Strings: Attempt review

Question 6
Correct

Mark 1.00 out of 1.00

Predict the Output of following Java Program.

class Test {

int x = 10;

public static void main(String[] args) {

System.out.println(x);
}

Select one:
a. Compile Time Error

b. 0

c. 10

d. Runtime Exception
44953
Your answer is correct.

The correct answer is: Compile Time Error

Question 7
Correct

Mark 1.00 out of 1.00

44953
Which members of a class can be accessed by other classes is determined by the ________________

Select one:
a. Access specifier

b. class

c. variables

d. constructor

Your answer is correct.

The correct answer is: Access specifier


44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121202&cmid=5214 4/6
2/19/24, 8:04 PM Pre-Quiz Arrays and Strings: Attempt review

Question 8
Correct

Mark 1.00 out of 1.00

package edu.ABC.model;

public class Account {

public static final float INTERTEST_RATE = 7.5;

Identify the correct options from the classes provided below.

Select one or more:


a.
import static edu.ABC.model.Account ;

public class Loan {


public double getInterest() {

} 44953
return INTEREST_RATE;

b. 
import static edu.ABC.model.Account.*;

public class Loan {

public double getInterest() {


return INTEREST_RATE;

c.
package edu.ABC.model;

public class Loan {


44953
public double getInterest() {

return INTEREST_RATE;

}
}

d. 
import edu.ABC.model.Account ;

public class Loan {

44953
public double getInterest() {

return Account.INTEREST_RATE;

Your answer is correct.

The correct answers are:


import static edu.ABC.model.Account.*;
public class Loan {
public double getInterest() {
return INTEREST_RATE;
}
}, import edu.ABC.model.Account ;
public class Loan {
public double getInterest() {
return Account.INTEREST_RATE;

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121202&cmid=5214 5/6
2/19/24, 8:04 PM Pre-Quiz Arrays and Strings: Attempt review
}
}

◄ Post-Quiz - Classes and Objects, Packages

Jump to...

Arrays Intro Video ►

44953

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121202&cmid=5214 6/6
2/19/24, 8:04 PM Post-Quiz - Classes and Objects, Packages: Attempt review


 Dashboard / My courses / Java / Class and Objects, Date API / Post-Quiz - Classes and Objects, Packages

Quiz review
Started on Sunday, 28 January 2024, 7:07 PM
State Finished
Completed on Sunday, 28 January 2024, 7:10 PM
Time taken 3 mins 30 secs
Marks 8.00/8.00
Grade 100.00 out of 100.00
Feedback Congratulations!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

44953
Which of the following is not a Java modifier?

Select one:
a.
protected

b. private

c.
public

d. 
virtual

Your answer is correct.


44953
The correct answer is: virtual

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121032&cmid=5213 1/7
2/19/24, 8:04 PM Post-Quiz - Classes and Objects, Packages: Attempt review

Question 2
Correct

Mark 1.00 out of 1.00

Observe the code

public class Sample {

public static void main(String [] args) {

int x = 6;
Sample p = new Sample();

p.display(x);
System.out.print(" main x = " + x);

void display(int x) {

44953
System.out.print(" display x = " + x++);

Given in command line - java Sample - What is the result?

Select one:
a.
Compilation fails.

b. 
display x = 6 main x = 6

c.
display x = 7 main x = 6

d. An exception is thrown at runtime. 44953


e.
display x = 6 main x = 7

f.
display x = 7 main x = 7

Your answer is correct.

The correct answer is:


display x = 6 main x = 6

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121032&cmid=5213 2/7
2/19/24, 8:04 PM Post-Quiz - Classes and Objects, Packages: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

Given:

public class Message {

String msg;
int noOfWords;

public Message() {

msg += " Thank you";

public Message(int noOfWords) {


this.noOfWords = noOfWords;

msg = "Welcome";

44953
Message();

public static void main(String args[]) {

Message m = new Message(5);


System.out.println(m.msg);

What will be the output ?

44953
Select one:
a. An exception is thrown at runtime

b. Compilation fails

c. Welcome Thank you

d. Welcome

e. The code runs with no output

f. Welcome Thank you 5

Your answer is correct.

The correct answer is: Compilation fails


44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121032&cmid=5213 3/7
2/19/24, 8:04 PM Post-Quiz - Classes and Objects, Packages: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

Given classes defined in two different files:

1. package p1;

2. public class Test {

3. public static void display(String [] a) { /* some code */ }


4. }

1. package p2;

2. public class TestMain {

3. public static void main(String[] args) {

44953
4. String [] names = new String[10];

5. // insert code here

6. }

7. }

Identify the statement to be written in line 5 in class TestMain to call the display method of class Test.

Select one:
a. p1.display(names);

44953
b.
display(names);

c. 
p1.Test.display(names);

d.
TestMain cannot use methods in p1

e.
import p1.Test.*; display(names);

Your answer is correct.


The correct answer is: p1.Test.display(names);

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121032&cmid=5213 4/7
2/19/24, 8:04 PM Post-Quiz - Classes and Objects, Packages: Attempt review

Question 5
Correct

Mark 1.00 out of 1.00

What is the outcome of the code?

public class Item {

private String description;

public String getDescription() {

return description;

public void setDescription(String description) {

this.description = description;

44953
public static void modifyDesc(Item item,String desc) {

item=new Item();

item.setDescription(desc);

public static void main(String[] args) {

Item it=new Item();

it.setDescription("Gobstopper");

Item it2=new Item();

it2.setDescription("Fizzylifting");

it.modifyDesc(it,"Scrumdiddlyumptious");

44953
System.out.println(it.getDescription());

System.out.println(it2.getDescription());

}
}

Select one:
a. Gobstopper

Fizzylifting

b. Scrumdiddlyumptious

Fizzylifting

c. Scrumdiddlyumptious

d. Gobstopper
44953
Scrumdiddlyumptious

e. Compilation fails

Your answer is correct.

The correct answer is: Gobstopper


Fizzylifting

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121032&cmid=5213 5/7
2/19/24, 8:04 PM Post-Quiz - Classes and Objects, Packages: Attempt review

Question 6
Correct

Mark 1.00 out of 1.00

Predict the output.

class X

void display(int a)
{

System.out.println("INT");

void display(double d)

44953
System.out.println("DOUBLE");

public class Sample

public static void main(String[] args)

new X().display(100);

}
}
44953
Select one:
a. INT

b. Compilation Fails

c. DOUBLE

d. Ambiguity error

Your answer is correct.


The correct answer is: INT
44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121032&cmid=5213 6/7
2/19/24, 8:04 PM Post-Quiz - Classes and Objects, Packages: Attempt review

Question 7
Correct

Mark 1.00 out of 1.00

The methods of a class with the ____________ access specifier cannot be accessed in its subclass class of different package.

Select one:
a. protected

b. default

c. public

Your answer is correct.


We call the access specifier default as “package level access” because, in a clss, members declared as default can be accessed only
within the package in which it is declared.

44953
The correct answer is: default

Question 8
Correct

Mark 1.00 out of 1.00

Integer x1 = new Integer(120);

int x2 = 120;

System.out.println( x1 == x2 );

44953
What will be the output of the above code fragment?

Select one:
a. true

b. Compilation Error

c. false

d.
CastException

e.
Runtime Exception

Your answer is correct.


44953
The correct answer is: true

◄ Calculate Expiry Date - Use Calendar

Jump to...

Pre-Quiz Arrays and Strings ►

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1121032&cmid=5213 7/7
2/19/24, 8:04 PM Test your understanding - Packages: Attempt review


 Dashboard / My courses / Java / Class and Objects, Date API / Test your understanding - Packages

Quiz review
Started on Sunday, 28 January 2024, 6:51 PM
State Finished
Completed on Sunday, 28 January 2024, 6:53 PM
Time taken 1 min 59 secs
Marks 5.00/5.00
Grade 100.00 out of 100.00
Feedback Congratulations!!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

Choose the correct order of the code 44953


public class Main---------------- 1
import java.util.Scanner;-------- 2
{------------------------------------- 3

//Some code here----------------- 4


}------------------------------------ 5
package test;--------------------- 6

44953
Select one:
a. 6 1 3 2 4 5

b. 6 2 1 3 4 5

c. 6 1 2 3 4 5

d. 2 6 1 3 4 5

Your answer is correct.


The correct answer is:
621345
44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120771&cmid=5205 1/5
2/19/24, 8:04 PM Test your understanding - Packages: Attempt review

Question 2
Correct

Mark 1.00 out of 1.00

Given the below code :

import static java.lang.Math.PI; 

public class AreaCalculator {


public double calculateArea(double radius) {

double area = PI * radius * radius; //Instead of Math.PI

return area;
}

}
select the correct statement to use the static variable PI.

44953
Your answer is correct.

The correct answer is:

Given the below code :

[import static java.lang.Math.PI;]

public class AreaCalculator {


public double calculateArea(double radius) {

double area = PI * radius * radius; //Instead of Math.PI

}
return area;
44953
}
select the correct statement to use the static variable PI.

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120771&cmid=5205 2/5
2/19/24, 8:04 PM Test your understanding - Packages: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

Given the class Book and Library in two different packages :

1. package model;

2. public class Book {


3. private static void countBook { }

4. }

1. package util;

2. public class Library {


3. public static void main(String[] args) {

4. // insert code here

44953
5. }

6. }
What is required at line 4 in class Library to use the countBook method of Book class?

Select one:
Book.countBook();

util.Library.countBook();

Library class cannot use the countBook method in Book class.

countBook();

model.Book.countBook();

44953
countBook() cannot be invoked since the method is declared private.

The correct answer is: Library class cannot use the countBook method in Book class.

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120771&cmid=5205 3/5
2/19/24, 8:04 PM Test your understanding - Packages: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

Assume class Calculator in package p1 and CalculatorService class in package p2 as shown below.

package p1;

public class Calculator {

__________ static void calculate(){

//some code here


}

package p2;

import p1.Calculator;

public class CalculatorService {

44953
public void display(){

Calculator.calculate();

What can be the valid access specifier for the calculate method in Calculator class so that it can be accessed from CalculatorService
class?

Select one:
private

Any access specifier except private

44953
protected

default

public

If a method defined within a class in one package has to be invoked from outside, then that method has to be declared public.

The correct answer is: public

Question 5
Correct

44953
Mark 1.00 out of 1.00

Given the class Book in packages p1 and class Main in package p2. In main to create an object of Book, which of the following are
valid.

Select one:
p1.Book bookObj=new Book();

Book bookObj=new Book();

p1.Book bookObj=new p1.Book();

Since the Book class is present within p1 package, it has to be accessed as "p1.Book", everytime, from package p2.

The correct answer is: p1.Book bookObj=new p1.Book();

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120771&cmid=5205 4/5
2/19/24, 8:04 PM Test your understanding - Packages: Attempt review

◄ Test your understanding - Static

Jump to...

Student Details - Constructor ►

44953

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120771&cmid=5205 5/5
2/19/24, 8:03 PM Test your understanding - Static: Attempt review


 Dashboard / My courses / Java / Class and Objects, Date API / Test your understanding - Static

Quiz review
Started on Sunday, 28 January 2024, 6:48 PM
State Finished
Completed on Sunday, 28 January 2024, 6:51 PM
Time taken 2 mins 58 secs
Marks 4.00/5.00
Grade 80.00 out of 100.00
Feedback
Congratulations!!! You have passed by securing more than 80%

44953

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120709&cmid=5204 1/7
2/19/24, 8:03 PM Test your understanding - Static: Attempt review

Question 1
Correct

Mark 1.00 out of 1.00

Observe the below code

public class Product


{

int productId;

String productName;
static int count = 0;

public Product(int pid,String name){

productId = pid;

productName=name;

44953
count++;

public static void main(String arg[]){

Product p1=new Product(101,"Screws");

System.out.println("Count is "+Product.count); 

Product p2=new Product(102,"Nuts");


Product p3=new Product(103,"Nails");

}
44953
System.out.println("Count is "+Product.count); 

choose the options correctly so that the output will be

Count is 1

Count is 3

Note: You can use the same option multiple times

Your answer is correct.


The correct answer is:
44953
Observe the below code
public class Product

int productId;

String productName;

static int count = 0;

public Product(int pid,String name){

productId = pid;

productName=name;

count++;

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120709&cmid=5204 2/7
2/19/24, 8:03 PM Test your understanding - Static: Attempt review
}

public static void main(String arg[]){

Product p1=new Product(101,"Screws");


[System.out.println("Count is "+Product.count);]

Product p2=new Product(102,"Nuts");

Product p3=new Product(103,"Nails");

[System.out.println("Count is "+Product.count);]

}
}

choose the options correctly so that the output will be

Count is 1

Count is 3

44953
Note: You can use the same option multiple times

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120709&cmid=5204 3/7
2/19/24, 8:03 PM Test your understanding - Static: Attempt review

Question 2
Incorrect

Mark 0.00 out of 1.00

Observe the code :

public class Employee {

String name;

static int employeeCount;

//Line 1
}

Which of the following code can be included in Line 1?

Select one or more:

public void display(){


System.out.println("Employee count "+employeeCount);

}
44953
public void display(){

System.out.println("Employee Name"+name);


public static void display() {

System.out.println("Employee Name"+name);

public static void display(){ 44953 

System.out.println("Employee count "+employeeCount);

From a static method, we can access only static members. Non static members cannot be accessed from static methods.
However, from a non static method, we can access both static and non static members.
The correct answers are:

44953
public static void display(){
System.out.println("Employee count "+employeeCount);
},
public void display(){
System.out.println("Employee count "+employeeCount);
},
public void display(){
System.out.println("Employee Name"+name);
}

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120709&cmid=5204 4/7
2/19/24, 8:03 PM Test your understanding - Static: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

For the below code, what are the valid ways to invoke display method in the main method.

public class Test {

public static void display(){

public class Main {

public static void main(String a[]){

//Invoke the display method

Select one or more:


new Test().display();44953
display();

Test.display();

Static method can be invoked either by using the object instance or using the class name.

The correct answers are: Test.display();, new Test().display();

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120709&cmid=5204 5/7
2/19/24, 8:03 PM Test your understanding - Static: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

Choose the correct option :

public class Flight{

int flightId;

static int noOfSeats;

public static void display(){

System.out.println("No of seats "+noOfSeats); 

44953
Non static members cannot be accessed from static methods. If we want to access non static members from a static method it is
possible by creating an object. Hence, only "noOfSeats" can be accessed, not "flightId".

The correct answer is:


Choose the correct option :

public class Flight{

int flightId;

static int noOfSeats;

public static void display(){

44953
[System.out.println("No of seats "+noOfSeats);]

Question 5
Correct

Mark 1.00 out of 1.00

Match the following :

non static method 44953


Can access both static and non static members 

static method
Can access static members only 

Your answer is correct.


The correct answer is: non static method → Can access both static and non static members, static method → Can access static members only

◄ Test Your understanding - Constructor

Jump to...

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120709&cmid=5204 6/7
2/19/24, 8:03 PM Test your understanding - Static: Attempt review

Test your understanding - Packages ►

44953

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120709&cmid=5204 7/7
2/19/24, 8:03 PM Test Your understanding - Constructor: Attempt review


 Dashboard / My courses / Java / Class and Objects, Date API / Test Your understanding - Constructor

Quiz review
Started on Sunday, 28 January 2024, 6:46 PM
State Finished
Completed on Sunday, 28 January 2024, 6:47 PM
Time taken 1 min 17 secs
Marks 4.00/5.00
Grade 80.00 out of 100.00
Feedback Congratulations!!! You have passed by securing more than 80%

44953

44953

44953


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120665&cmid=5203 1/7
2/19/24, 8:03 PM Test Your understanding - Constructor: Attempt review

Question 1
Correct

Mark 1.00 out of 1.00

Observe the below code.

public class Student {

private int id;

private String name;


private char grade;

//Constructor 1
public Student() {

id=0;

name= " ";

44953
}

//Constructor 2

public Student(int id, String name) {

this.id=id;
this.name=name;

Choose the constructor that is invoked, when an object is created as shown below.

new Student(); Constructor 1 

new Student(54, "John");


44953
Constructor 2 

Your answer is correct.


The correct answer is:

Observe the below code.

public class Student {

private int id;


44953
private String name;
private char grade;

//Constructor 1

public Student() {

id=0;

name= " ";


}

//Constructor 2

public Student(int id, String name) {

this.id=id;

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120665&cmid=5203 2/7
2/19/24, 8:03 PM Test Your understanding - Constructor: Attempt review
this.name=name;

Choose the constructor that is invoked, when an object is created as shown below.

new Student(); [Constructor 1]


new Student(54, "John"); [Constructor 2]

Question 2
Incorrect

Mark 0.00 out of 1.00

44953
You are given with few classes.

Match the code with the type of constructor available in the class.

public class Student {

public Student {

} Parameterized Constructor 

public class Student {

} 44953
public Student(int studentId, String name) {
Default constructor 

public class Student {

} No-argument Constructor 

Your answer is incorrect.


The correct answer is: public class Student {
public Student

}
{
44953
} → No-argument Constructor, public class Student {
public Student(int studentId, String name) {

} → Parameterized Constructor, public class Student {


} → Default constructor


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120665&cmid=5203 3/7
2/19/24, 8:03 PM Test Your understanding - Constructor: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

Observe the code below.

public class Student {

int studentId;

String name;

char grade;

public Student(int studentId, String name, float mark) {

this.studentId = studentId;

this.name=name;

calculateGrade(mark);

44953
public void calculateGrade(float mark){

if(mark>90)

grade='A';

else

grade='B';

For the code


Student s = new Student(1,"Peter",95);
44953
What will be the output?

Select one:

Compiles successfully

Compilation error because of the parameter – mark - in constructor. It should be grade instead of mark.

Compilation error because cannot call methods from constructor

44953
Your answer is correct.
The correct answer is: Compiles successfully


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120665&cmid=5203 4/7
2/19/24, 8:03 PM Test Your understanding - Constructor: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

Observe the below class.

class Product{

int productId;

String productName;

Product {

productId=0; productName=” ”;

Product(int id, String name) {

//access Product() ---- Line 1

productId=id;

44953
productName=name;

Identify the valid option which is used to invoke the no argument constructor, Product(), at Line 1.

Select one:
Product

super();

Product();

this();
44953
this() invokes the current object's no argument constructor.

The correct answer is: this();

44953


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120665&cmid=5203 5/7
2/19/24, 8:03 PM Test Your understanding - Constructor: Attempt review

Question 5
Correct

Mark 1.00 out of 1.00

choose the code so that the constructor for Student class is overloaded correctly.

public class Student {

private int studentId;

private String name;


private float grade;

public Student(int studentId, String name) {

this.studentId=studentId;this.name=name; 

public Student(int studentId, String name, float grade) {

this(studentId,name);
44953 

this.grade=grade; 

44953
Your answer is correct.

The correct answer is:

choose the code so that the constructor for Student class is overloaded correctly.

public class Student {

private int studentId;

private String name;

private float grade;

44953
public Student(int studentId, String name) {

[this.studentId=studentId;this.name=name;]

public Student(int studentId, String name, float grade) {

[this(studentId,name);]

[this.grade=grade;]


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120665&cmid=5203 6/7
2/19/24, 8:03 PM Test Your understanding - Constructor: Attempt review

◄ Test Your understanding - Classes and Objects

Jump to...

Test your understanding - Static ►

44953

44953

44953


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120665&cmid=5203 7/7
2/19/24, 8:03 PM Test Your understanding - Classes and Objects: Attempt review


 Dashboard / My courses / Java / Class and Objects, Date API / Test Your understanding - Classes and Objects

Quiz review
Started on Sunday, 28 January 2024, 6:38 PM
State Finished
Completed on Sunday, 28 January 2024, 6:41 PM
Time taken 2 mins 56 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

Mark 1.00 out of 1.00

44953
___ and _____ are the access specifiers that can be applied to top level Class.

Select one or more:


a. virtual

b. protected

c. public

d. default

Your answer is correct.


The correct answers are: default, public
44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120518&cmid=5202 1/8
2/19/24, 8:03 PM Test Your understanding - Classes and Objects: Attempt review

Question 2
Correct

Mark 1.00 out of 1.00

class Sample{

private double num = 100;


private int square(int a){

return a*a;

}
}

public class Test{

public static void main(String args[]){


Sample obj = new Sample();

System.out.println(obj.num);
System.out.println(obj.square(10));

}
}
44953
Select one:
a. 100

b. Compile time error

c. Run time error

d. Executes but no output

Your answer is correct.


The correct answer is: Compile time error 44953
Question 3
Correct

Mark 1.00 out of 1.00

Choose the appropriate access specifier for the attribute value so that it can be accessed from anywhere.

class Test

public  int value; 44953


}

Your answer is correct.


The correct answer is:
Choose the appropriate access specifier for the attribute value so that it can be accessed from anywhere.

class Test

[public] int value;

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120518&cmid=5202 2/8
2/19/24, 8:03 PM Test Your understanding - Classes and Objects: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

Choose the appropriate return type for the getters and setters provided below.
class Test

private int value;

public void  setValue(int value){//some code}

public int  getValue(){//some code}

Your answer is correct.

The correct answer is:

44953
Choose the appropriate return type for the getters and setters provided below.

class Test

{
private int value;

public [void] setValue(int value){//some code}

public [int] getValue(){//some code}

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120518&cmid=5202 3/8
2/19/24, 8:03 PM Test Your understanding - Classes and Objects: Attempt review

Question 5
Correct

Mark 1.00 out of 1.00

Consider the below code snippet and determine the output.

class Student

{ private int studentId;

private float average;

class Test

public static void main(String a[])

Student s=new Student();

s.studentId=123;

}
44953
System.out.println(s.studentId);

Select one:
Compile time error

Any value

44953
0

Your answer is correct.


Private variables can be accessed only within the class. They cannot be accessed outside the class.
The correct answer is: Compile time error

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120518&cmid=5202 4/8
2/19/24, 8:03 PM Test Your understanding - Classes and Objects: Attempt review

Question 6
Partially correct

Mark 0.67 out of 1.00

Analyze the below program, and fill the correct code so that it produces the below output:

101

class Book {

private int bookId;

private double bookPrice;

public int getBookId() {

return bookId;

public void setBookId(int bookId) {

44953
this.bookId = bookId;

public double getBookPrice() {

return bookPrice;

public void setBookPrice(double bookPrice) {

this.bookPrice = bookPrice;

public class Test {


public static void main(String a[]) {

Book bobj=new Book();


44953
System.out.println(bobj.getBookPrice()); 

bobj.setBookId(101); 

System.out.println(bobj.getBookId()); 

Note : Same option can be used multiple times. Analyse and use the correct option

44953
Your answer is partially correct.

You have correctly selected 2.


The correct answer is:

Analyze the below program, and fill the correct code so that it produces the below output:

101

class Book {

private int bookId;

private double bookPrice;


public int getBookId() {

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120518&cmid=5202 5/8
2/19/24, 8:03 PM Test Your understanding - Classes and Objects: Attempt review
return bookId;

public void setBookId(int bookId) {

this.bookId = bookId;

public double getBookPrice() {


return bookPrice;

public void setBookPrice(double bookPrice) {

this.bookPrice = bookPrice;

public class Test {

public static void main(String a[]) {

44953
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

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120518&cmid=5202 6/8
2/19/24, 8:03 PM Test Your understanding - Classes and Objects: Attempt review

Question 7
Correct

Mark 1.00 out of 1.00

The below code snippet shows an error

cannot find symbol:

System.out.println("BookId:"+bobj.getId());

public class Book {

private int bookId;

private double bookPrice;

public int getBookId() {

return bookId;

public void setBookId(int bookId) {

this.bookId = bookId;

}
44953
public double getBookPrice() {

return bookPrice;

public void setBookPrice(double bookPrice) {

this.bookPrice = bookPrice;

public class Test {

44953
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());

44953
Analyze the above code and select the correct reason for the error.

Select one:
bobj is not initialized

Getter method should not be called inside System.out.println

getId method is not present in the book class

“+” symbol should not be used in System.out.println

Your answer is correct.


When we specify the methodname or variablename or classname wrongly,then we will get an error “cannot find symbol”. The compiler
tries to fetch the methodname "getId" from the book class, where it is not defined.

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120518&cmid=5202 7/8
2/19/24, 8:03 PM Test Your understanding - Classes and Objects: Attempt review
The correct answer is: getId method is not present in the book class

Question 8
Correct

Mark 1.00 out of 1.00

public class Employee {

private int employeId;

private float salary;

public void  setSalary  (float salary1) {

if(salary>0){

salary=salary1;
}

} 44953
}

Your answer is correct.

The correct answer is:


public class Employee {

private int employeId;

private float salary;


44953
public [void] [setSalary](float salary1) {

if(salary>0){

salary=salary1;

}
44953

◄ Classes and Objects, Packages - Demo

Jump to...

Test Your understanding - Constructor ►

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120518&cmid=5202 8/8
2/19/24, 8:02 PM Pre-Quiz - Classes and Objects, Packages: Attempt review


 Dashboard / My courses / Java / Class and Objects, Date API / Pre-Quiz - Classes and Objects, Packages

Quiz review
Started on Sunday, 28 January 2024, 6:36 PM
State Finished
Completed on Sunday, 28 January 2024, 6:37 PM
Time taken 1 min 13 secs
Marks 5.00/5.00
Grade 100.00 out of 100.00
Feedback Congratulations!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

State True or False 44953


When using eclipse whichever classes are needed for the present class can be imported automatically.

Select one:
True 

False

The correct answer is 'True'.

44953

44953


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120478&cmid=5181 1/4
2/19/24, 8:02 PM Pre-Quiz - Classes and Objects, Packages: Attempt review

Question 2
Correct

Mark 1.00 out of 1.00

Predict the output.

public class Test {

public static void main(String args[])

{
int a = 2, b = 0;

for ( ; b < 20; ++b) {


if (b % a == 0)

continue;

else if (b == 10)

44953
break;

else

System.out.print(b + " ");

}
}

Select one:
a. 
1 3 5 7 9 11 13 15 17 19

b.
2 4 6 8 12 14 16 18

c. Code executes but gives no output

d.
44953
13579

Your answer is correct.

The correct answer is:


1 3 5 7 9 11 13 15 17 19

Question 3

44953
Correct

Mark 1.00 out of 1.00

In Eclipse IDE, if we provide a workspace, it should already exist. If not, it will not open.

Select one:
True

False 

The correct answer is 'False'.


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120478&cmid=5181 2/4
2/19/24, 8:02 PM Pre-Quiz - Classes and Objects, Packages: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

What will be the output of the following code?

int i=20;
if(i>10)

System.out.println( "The value of i is "+i);

i++;

if(i%2!=0)
break;

Select one: 44953



a.
Compilation fails

b.
The value of i is 20

c. Code compiles but will not execute

d.
The value of i is 10

Your answer is correct.

The correct answer is: Compilation fails


44953

44953


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120478&cmid=5181 3/4
2/19/24, 8:02 PM Pre-Quiz - Classes and Objects, Packages: Attempt review

Question 5
Correct

Mark 1.00 out of 1.00

switch(a)

default:

System.out.println("Welcome");

}
Of which data types can the variable ‘a’ be?

1. long

2. byte

3. int

4. char

44953
5. float

6. short

Select one:
a. 
2,3, 4 and 6

b.
1 and 3

c.
3 and 4

d. 3, 4 and 5

Your answer is correct.

The correct answer is:


44953
2,3, 4 and 6

◄ Post-Quiz - Eclipse IDE

Jump to...

Classes and Objects Intro video ►

44953


https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120478&cmid=5181 4/4
2/19/24, 8:02 PM Post-Quiz - Eclipse IDE: Attempt review


 Dashboard / My courses / Java / Eclipse IDE / Post-Quiz - Eclipse IDE

Quiz review
Started on Sunday, 28 January 2024, 6:34 PM
State Finished
Completed on Sunday, 28 January 2024, 6:35 PM
Time taken 1 min 1 sec
Marks 4.00/4.00
Grade 100.00 out of 100.00
Feedback Congratulations!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

44953
We can move an already existing project in eclipse to another location by compressing it. This we call as ________ the project.

Select one:
a. Exporting
b. Importing

The correct answer is: Exporting

Question 2

44953
Correct

Mark 1.00 out of 1.00

State True or False.


When typing the code in code editor, it fixes the compilation error. It also assists in how to fix that error.

Select one:
a. True
b. False

The correct answer is: True

Question 3
44953
Correct

Mark 1.00 out of 1.00

In Eclipse, the plugin that is needed for Java Development is ______________.

Select one:
a. CDT
b. JavaPlugin
c. JDT
d. PyDev

The correct answer is: JDT

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120453&cmid=5179 1/2
2/19/24, 8:02 PM Post-Quiz - Eclipse IDE: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

A project developed on one machine can be included in the current workspace by ___________ that project.

Select one:
a. Importing
b. Exporting

The correct answer is: Importing

◄ Eclipse IDE - Demo

Jump to...

44953 Pre-Quiz - Classes and Objects, Packages ►

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120453&cmid=5179 2/2
2/19/24, 8:02 PM Pre-Quiz - Eclipse IDE: Attempt review


 Dashboard / My courses / Java / Eclipse IDE / Pre-Quiz - Eclipse IDE

Quiz review
Started on Sunday, 28 January 2024, 6:30 PM
State Finished
Completed on Sunday, 28 January 2024, 6:32 PM
Time taken 2 mins
Marks 7.00/8.00
Grade 87.50 out of 100.00
Feedback Congratulations!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

State True or False 44953


For compiling a java code we have separate compilers for different OS.

Select one:
True

False 

The correct answer is 'False'.

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120381&cmid=5175 1/5
2/19/24, 8:02 PM Pre-Quiz - Eclipse IDE: Attempt review

Question 2
Correct

Mark 1.00 out of 1.00

Which of the following options remain true for case constants in a switch construct?

Select one:
a.
The code with the switch construct gives a compilation error when there is a duplicate case label

b.
If no case matches and there is no default label, then it will result in a compilation error

c.
If no case matches and there is no default label, then no further action is taken and the switch statement completes abnormally

d. 
If no case matches but there is a default label, then all statements after the matching default label in the switch block are

44953
executed in sequence.

e. If any one of the case constants has a match with the expression, then all statements after the matching case label in the switch
block are executed in sequence

Your answer is correct.


The correct answers are: If no case matches but there is a default label, then all statements after the matching default label in the switch block are
executed in sequence. , The code with the switch construct gives a compilation error when there is a duplicate case label , If any one of the case
constants has a match with the expression, then all statements after the matching case label in the switch block are executed in sequence

Question 3
Correct 44953
Mark 1.00 out of 1.00

Which edition of java is used for developing web application?

Select one:
a.
J2ME

b. 
J2EE

c.
J2SE 44953
d. All these options

Your answer is correct.


The correct answer is: J2EE

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120381&cmid=5175 2/5
2/19/24, 8:02 PM Pre-Quiz - Eclipse IDE: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

Predict the output

int a=0;
if(a)

System.out.println( "Hello");

else

System.out.println( "Hai");

Select one:
a.
Hello

b. Compilation Fails
44953
c. Need to include the braces { } for the code to work

d.
Hai

Your answer is correct.


The correct answer is: Compilation Fails

Question 5

44953
Incorrect

Mark 0.00 out of 1.00

__________ generates the byte code for a given file with .java extension.

Select one:
a. 
JVM

b.
JDK

c. JRE

Your answer is incorrect.


44953
The correct answer is: JDK

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120381&cmid=5175 3/5
2/19/24, 8:02 PM Pre-Quiz - Eclipse IDE: Attempt review

Question 6
Correct

Mark 1.00 out of 1.00

What will be the output of the program?

public class Sample

public static void main(String [] args)

{
int i = 10;

do while ( i < 10 )

System.out.print("The value of i is " + i);

while ( i > 10 ) ;

44953
}

Select one:
a. The value of i is 10

b. The value of i is 10 The value of i is 10

c. Compilation error

d. No output is produced.

Your answer is correct.


44953
The statement for the do..while block is - while(i<10) then print value of i. As condition is false, this statement doesn't get executed.
Also while condition for the do..while loop is i > 10. This also results in false. So it comes out of the loop.

The correct answer is: No output is produced.

Question 7
Correct

Mark 1.00 out of 1.00

Who executes the byte code in java?


44953
Select one:
a.
JRE

b. 
JVM

c.
JDK

d. OS

Your answer is correct.


The correct answer is: JVM

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120381&cmid=5175 4/5
2/19/24, 8:02 PM Pre-Quiz - Eclipse IDE: Attempt review

Question 8
Correct

Mark 1.00 out of 1.00

State True or False

For compiling a java code we have separate compilers for different OS.

Select one:
True

False 

The correct answer is 'False'.

44953
◄ Post-Quiz - Introduction to Java

Jump to...

Eclipse IDE ►

44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120381&cmid=5175 5/5
2/19/24, 8:01 PM Post-Quiz - Introduction to Java: Attempt review


 Dashboard / My courses / Java / Introduction To Java / Post-Quiz - Introduction to Java

Quiz review
Started on Sunday, 28 January 2024, 6:24 PM
State Finished
Completed on Sunday, 28 January 2024, 6:27 PM
Time taken 2 mins 52 secs
Marks 9.00/9.00
Grade 100.00 out of 100.00
Feedback Congratulations!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

44953
In a for loop, if the number of statements are greater than one, which of the following needs to be inserted at the beginning and the end
of the loop?

Select one:
a. 
French curly braces{ }

b.
Parenthesis

c.
Square bracket [ ]

44953
d. Arrows<>

Your answer is correct.

The correct answer is: French curly braces{ }

Question 2
Correct

Mark 1.00 out of 1.00

44953
JRE comprises of ___________ and ___________.

Select one or more:


a. tools

b. API

c. JVM

d. JDK

Your answer is correct.

The correct answers are: API


, JVM

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120285&cmid=5173 1/5
2/19/24, 8:01 PM Post-Quiz - Introduction to Java: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

The ________________ statement causes the program execution to stop and JVM to shut down.

Select one:
a.
exit

b. 
System.exit

c. break

d.
return

Your answer is correct.


The correct answer is:
44953
System.exit

Question 4
Correct

Mark 1.00 out of 1.00

Identify the features of java.

Select one:
a.
44953
Direct Access to memory using pointers

b. 
Multi threading

c. Less security

d.
Exception Handling

Your answer is correct.

44953
The correct answers are: Exception Handling, Multi threading

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120285&cmid=5173 2/5
2/19/24, 8:01 PM Post-Quiz - Introduction to Java: Attempt review

Question 5
Correct

Mark 1.00 out of 1.00

The main method in java should ___________.

Select one:
a. return int

b. be public static

c.
take boolean[] as argument

d. be private static

Your answer is correct.

44953
The correct answer is: be public static

Question 6
Correct

Mark 1.00 out of 1.00

A continue statement makes the execution jump to ______________.

Select one:
a. the next iteration of the loop

44953
b. the statement just after continue

c. the end of the loop

d. the first statement of the loop

Your answer is correct.


continue statement can be used in loops. It causes the loop to skip that particular iteration and jump to the next iteration of the loop.

The correct answer is: the next iteration of the loop

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120285&cmid=5173 3/5
2/19/24, 8:01 PM Post-Quiz - Introduction to Java: Attempt review

Question 7
Correct

Mark 1.00 out of 1.00

The break statement cannot be present for _____________ construct.

Select one:
a. do while

b.
for

c.
while

d. 
if

Your answer is correct.


The correct answer is:
if 44953
Question 8
Correct

Mark 1.00 out of 1.00

Using Java we can develop ___________________.

Select one:

44953
a. Desktop Application

b. Web Application

c. Both the options

d. None of these options

Your answer is correct.

The correct answer is: Both the options

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120285&cmid=5173 4/5
2/19/24, 8:01 PM Post-Quiz - Introduction to Java: Attempt review

Question 9
Correct

Mark 1.00 out of 1.00

What will be the output of the program?

public class Sample {

final static short a = 2;

public static int b = 0;

public static void main(String [] args) {

for (int c=0; c < 4; c++)

switch (c) {

case a: System.out.print("a ");

default: System.out.print("default ");

44953
case a-1: System.out.print("a-1 ");

break;

case a-2: System.out.print("a-2 ");

Select one:
a.

44953
a-2 a-1 a default default

b.
a-2 a-1 a default a-1

c. 
a-2 a-1 a default a-1 default a-1

d. a default a-1

Your answer is correct.

The correct answer is:


a-2 a-1 a default a-1 default a-1

44953
◄ Ludo King

Jump to...

Pre-Quiz - Eclipse IDE ►

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120285&cmid=5173 5/5
2/19/24, 8:01 PM Test Your Understanding - Introduction to Java: Attempt review


 Dashboard / My courses / Java / Introduction To Java / Test Your Understanding - Introduction to Java

Quiz review
Started on Monday, 29 January 2024, 5:54 AM
State Finished
Completed on Monday, 29 January 2024, 5:59 AM
Time taken 5 mins 7 secs
Marks 11.00/11.00
Grade 100.00 out of 100.00
Feedback Congratulations!!! You have passed by securing more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

44953
What value is stored in i at the end of this loop?
for(int i =1;i<=10;i++)

Select one:
a. 11

b. 9

c. 10

d. 1

44953
The program control will exit the for loop only when the condition specified in the for loop has failed. Hence, the value of i will be 11.
The correct answer is: 11

Question 2
Correct

Mark 1.00 out of 1.00

44953
French curly braces { } is a must if the for loop executes more than one statement. State true or false.

Select one:
True 

False

The correct answer is 'True'.

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1127854&cmid=5151 1/7
2/19/24, 8:01 PM Test Your Understanding - Introduction to Java: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

What will be the output of the program?


Given:
10. int x = 0;

11. int y = 10;

12. do {
13. y--;

14. ++x;

15. } while (x < 5);


16. System.out.print(x + "," + y);

What is the result?

Select one:
a. 5,5
44953
b. 6,5

c. 5,6

d. 6,6

x is assigned 0 and y, 10 initially. During each iteration x is incremented by 1 and y is decremented by 1.

The iteration stops when x equals 5. At this stage y also would have reached the value 5. Hence the output 5 5.
The correct answer is: 5,5
44953

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1127854&cmid=5151 2/7
2/19/24, 8:01 PM Test Your Understanding - Introduction to Java: Attempt review

Question 4
Correct

Mark 1.00 out of 1.00

What is the output of this program?

class selection_statements {

public static void main(String args[])


{

int var1 = 5;

int var2 = 6;

if ((var2 = 1) == var1)

System.out.print(var2);
else

System.out.print(++var2);

44953
}

Select one:
a. 1

b. 4

c. 3

d. 2

44953
Observe the if construct. var 2 is assigned 1. 1 does not equal 5, hence else block will get executed. Pre increment to var2 results in 2
(var2 variable now has the value 1, not 6). Hence 2 gets printed.

The correct answer is: 2

Question 5
Correct

Mark 1.00 out of 1.00

for
44953
 looping structure should be used when the iterations are known.

Your answer is correct.

The correct answer is:

[for] looping structure should be used when the iterations are known.

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1127854&cmid=5151 3/7
2/19/24, 8:01 PM Test Your Understanding - Introduction to Java: Attempt review

Question 6
Correct

Mark 1.00 out of 1.00

What is the output of this program?

1. class Crivitch {
2. public static void main(String [] args) {
3. int x = 10;
4.
5. do { } while (x++ < y);
6. System.out.println(x);
7. }
8. }

Which statement, inserted at line 4, produces the output 12?

Select one:
a. int y=13;
44953
b. int y=11;

c. int y=10;

d. int y=12;

Your answer is correct.

The correct answer is:


int y=11;

44953
Question 7
Correct

Mark 1.00 out of 1.00

Which of the following loops will execute the body of loop even when condition controlling the loop is initially false?

Select one:
a. while

b. do-while

c. for
44953
Your answer is correct.

The correct answer is:


do-while

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1127854&cmid=5151 4/7
2/19/24, 8:01 PM Test Your Understanding - Introduction to Java: Attempt review

Question 8
Correct

Mark 1.00 out of 1.00

What will be the output of the program?


for(int i = 0; i < 3; i++)
{
switch(i)
{
case 0: break;
case 1: System.out.print("one ");
case 2: System.out.print("two ");
case 3: System.out.print("three ");
}
}
System.out.println("done");

Select one:
a. done 44953
b. one two three done

c. one two doneone two done

d. one two three two three done

Switch takes the values 0, 1 and 2.

Case 0 has nothing to execute.

44953
Execution of Case 1 is followed by 2 and 3 since there's no break statement encountered. So, one two three.

Execution of Case 2 is followed 3 since there's no break statement encountered like before. So, two three.

This is followed by "done".

The correct answer is: one two three two three done

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1127854&cmid=5151 5/7
2/19/24, 8:01 PM Test Your Understanding - Introduction to Java: Attempt review

Question 9
Correct

Mark 1.00 out of 1.00

What will be the output of the program?


int i = 1, j = -1;
switch (i)
{
case 0, 1: j = 1; /* Line 4 */
case 2: j = 2;
default: j = 0;
}
System.out.println("j = " + j);

Select one:
a. j = 1

44953
b. j = -1

c. j = 0

d. Compilation fails.

One can not specify multiple case labels with commas, as in line 4. Hence compilation error.
The correct answer is: Compilation fails.

Question 10
Correct

Mark 1.00 out of 1.00

44953
The break statement causes an exit ___________

Select one or more:


a.
none of the options

b. 
from the innermost switch.

44953
c. from the innermost loop

d.
from the program.

Your answer is correct.


The correct answers are: from the innermost switch. , from the innermost loop

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1127854&cmid=5151 6/7
2/19/24, 8:01 PM Test Your Understanding - Introduction to Java: Attempt review

Question 11
Correct

Mark 1.00 out of 1.00

Fill in with appropriate datatype.

switch( byte  )
{

case value1 : ..........................

case value2 : ..........................

.......................................

default:
System.out.println("Hello");

44953
Switch in java works with primitive data types byte, short, char and int;
wrapper classes like Character, Byte, Short and Integer;
enumerated types (added in java 5) and String class (added in java 7)

The correct answer is:


Fill in with appropriate datatype.

switch([byte])
{

case value1 : ..........................

44953
case value2 : ..........................
.......................................

default:
System.out.println("Hello");
}

◄ Control Structures

44953
Jump to...

SampleCode_HelloWorld ►

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1127854&cmid=5151 7/7
2/19/24, 8:01 PM Pre-Quiz - Introduction to Java: Attempt review


 Dashboard / My courses / Java / Introduction To Java / Pre-Quiz - Introduction to Java

Quiz review
Started on Sunday, 28 January 2024, 6:19 PM
State Finished
Completed on Sunday, 28 January 2024, 6:20 PM
Time taken 37 secs
Marks 7.00/7.00
Grade 100.00 out of 100.00
Feedback Congratulations!! You have secured more than 80%

Question 1
Correct

Mark 1.00 out of 1.00

44953
To compile, debug and execute a program written in java, _______________ is required.

Select one:
a. 
JDK

b. JIT

c.
JRE

d.
JVM

Your answer is correct.

The correct answer is: JDK


44953
Question 2
Correct

Mark 1.00 out of 1.00

Who is the father of Java?

Select one:
a. James Gosling

b. Dennis Ritchie
44953
c.
Donald Knuth

d. Jim Gray

Your answer is correct.

The correct answer is: James Gosling

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120202&cmid=5139 1/3
2/19/24, 8:01 PM Pre-Quiz - Introduction to Java: Attempt review

Question 3
Correct

Mark 1.00 out of 1.00

How was Java initially named?

Select one:
a. GreenTalk

b. Algol
c. COBOL

d. The Oak

Your answer is correct.


The correct answer is: The Oak

Question 4
Correct
44953
Mark 1.00 out of 1.00

JVM is independent of OS

Select one:
True

False 

The correct answer is 'False'.


44953
Question 5
Correct

Mark 1.00 out of 1.00

What is Polymorphism?

Select one:
a. blueprint for an object

b. ability to have many forms


44953
c. hiding the properties

d.
ability to acquire the properties

Your answer is correct.


The correct answer is: ability to have many forms

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120202&cmid=5139 2/3
2/19/24, 8:01 PM Pre-Quiz - Introduction to Java: Attempt review

Question 6
Correct

Mark 1.00 out of 1.00

State true or false. Java is a structured programming language.

Select one:
True

False 

The correct answer is 'False'.

Question 7
Correct

44953
Mark 1.00 out of 1.00

Java is _____________________________.

Select one:
a. Platform independent

b. Platform dependent

Your answer is correct.


The correct answer is: Platform independent

44953
Jump to...

Introduction to Java - Intro Video ►

44953

https://accenturelearning.tekstac.com/mod/quiz/review.php?attempt=1120202&cmid=5139 3/3

You might also like