Skip to main content

IS5103 WEEK-4 QUIZE'S


WEEK-4


Q1. Suppose your method does not return any value, which of the following keywords can be used as a return type?

Select one:

A.

void

B.

int

C.

public

D.

double

E.

None of the above


Q2. Does the method call in the following method cause compile errors?


public static void main(String[] args) {
Math.pow(2, 4);
}

Select one:

A.

Yes

B.

No

Q3. You should fill in the blank in the following code with ________.


public class Test {
public static void main(String[] args) {
System.out.print("The grade is ");
printGrade(78.5);

System.out.print("The grade is ");
printGrade(59.5);
}

public static ________ printGrade(double score) {
if (score >= 90.0) {
System.out.println('A');
}
else if (score >= 80.0) {
System.out.println('B');
}
else if (score >= 70.0) {
System.out.println('C');
}
else if (score >= 60.0) {
System.out.println('D');
}
else {
System.out.println('F');
}
}
}

Select one:

A.

int

B.

double

C.

char

D.

void

E.

boolean

Q4. You should fill in the blank in the following code with ________.


public class Test {
public static void main(String[] args) {
System.out.print("The grade is " + getGrade(78.5));
System.out.print("\nThe grade is " + getGrade(59.5));
}

public static ________ getGrade(double score) {
if (score >= 90.0)
return 'A';
else if (score >= 80.0)
return 'B';
else if (score >= 70.0)
return 'C';
else if (score >= 60.0)
return 'D';
else
return 'F';
}
}

Select one:

A.

char

B.

void

C.

int

D.

double

E.

boolean

Q5. Given the following method


static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}
}

What is the output of the call nPrint('a', 4)?

Select one:

A.

aaa

B.

aaaa

C.

aaaaa

D.

invalid call

Q6. Given the following method


static void nPrint(String message, int n) {
while (n > 0) {
System.out.print(message);
n--;
}
}

What is k after invoking nPrint("A message", k)?

int k = 2;
nPrint("A message", k);

Select one:

A.

0

B.

1

C.

2

D.

3

Q7. Analyze the following code.


public class Test {
public static void main(String[] args) {
System.out.println(max(1, 2));
}

public static double max(int num1, double num2) {
System.out.println("max(int, double) is invoked");

if (num1 > num2)
return num1;
else
return num2;
}

public static double max(double num1, int num2) {
System.out.println("max(double, int) is invoked");

if (num1 > num2)
return num1;
else
return num2;
}
}

Select one:

A.

The program runs and prints 2 followed by "max(double, int)" is invoked.

B.

The program runs and prints 2 followed by "max(int, double)" is invoked.

C.

The program cannot compile because you cannot have the print statement in a non-void method.

D.

The program runs and prints "max(int, double) is invoked" followed by 2.

E.

The program cannot compile because the compiler cannot determine which max method should be invoked.

Q8. (char)('a' + Math.random() * ('z' - 'a' + 1)) returns a random character ________.

Select one:

A.

between 'b' and 'z'

B.

between 'b' and 'y'

C.

between 'a' and 'y'

D.

between 'a' and 'z'

Q9. Which of the following is the best for generating random integer 0 or 1?

Select one:

A.

(int)Math.random() + 1

B.

(int)(Math.random() + 0.5)

C.

(int)(Math.random() + 0.8)

D.

(int)Math.random()

E.

(int)(Math.random() + 0.2)


Q10. The client can use a method without knowing how it is implemented. The details of the implementation are encapsulated in the method and hidden from the client who invokes the method. This is known as ________.

Select one or more:

A.

encapsulation

B.

simplifying method

C.

method hiding

D.

information hiding





















































































Comments

Popular posts from this blog

IS5213 Data Science and Big Data Solutions

WEEK- 2 code  install.packages("dplyr") library(dplyr) Rajeshdf = read.csv('c:\\Insurance.csv') str(Rajeshdf)                        str(Rajeshdf) summary(Rajeshdf) agg_tbl <- Rajeshdf %>% group_by(Rajeshdf$JOB) %>%    summarise(total_count=n(),             .groups = 'drop') agg_tbl a = aggregate( x=Rajeshdf$HOME_VAL, by=list( Rajeshdf$CAR_TYPE), FUN=median, na.rm=TRUE ) a QUIZ 2. What famous literary detective solved a crime because a dog did not bark at the criminal? A). Sherlock Holmes 1.  In the Insurance data set, how many Lawyers are there? A).  1031 3. What two prefixes does the instructor use for variables when fixing the missing values? Select all that apply. A). IMP_ M_ 4. What is the median Home Value of a person who drives a Van? A).  204139 5. In the insurance data set, how many missing (NA) values does the variable AGE have? A) 7   1. What...

GE5103-2 Project Management [Aug 23 Syllabus]

    Some of the advantages of using time boxes and cycles in project coordination efforts include creating urgency, measuring progress, and allowing for predictable measurements. A)        True 2.    Even though most project managers are not contract specialists, they need to understand the process well enough to coordinate with the team. For the current assignment, you are looking at a short-term and small effort with a contractor of just a few hours without significant clarity. Which of the following would be the most applicable contract to use in this situation? A)        Time and materials 3. The project you are working on has had modifications to the plan from the start and even how the project is run. Project governance covers all of the 3 following except: A)        Naming The project manager 4. Of the following, which is most likely a trigger condition defined early in t...

GE5093 Design Thinking All Quizzes

  GE---5093-1D2-FA-2021 - Design Thinking Home My courses 2021-FA GE---5093-1D2-FA-2021 Week 1 Reading Quiz 1 Started on Sunday, October 31, 2021, 2:04 PM State Finished Completed on Sunday, October 31, 2021, 2:30 PM Time taken 25 mins 58 secs Grade 8.00  out of 10.00 ( 80 %) Top of Form Question  1 Correct 1.00 points out of 1.00 Flag question Question text A critical finding of Edward Lorenz related to Design Thinking was: Select one: a. An application of the caterpillar effect b. The idea of deterministic chaos or the "Butterfly Effect" c. Business leaders enjoy chaos d. Statistical modeling of weather was fairly accurate in the long term Feedback Your answer is correct. The correct answer is: The idea of deterministic chaos or the "Butterfly Effect" Question  2 Incorrect 0.00 point...