Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Recognition: Given an identifier, decide whether it is a legal one? Evaluate the

ID: 3569616 • Letter: R

Question

Recognition:

Given an identifier, decide whether it is a legal one?

Evaluate the result of a given expression?

Given two code segments, answer whether they are equivalent or not?

Write the output for a given code segment?

Coding:

Given a mathematical expression, write a corresponding Java expression.?

Given a logical condition in plain English, write a corresponding logical condition in

Java?

Find and correct errors in a code segment?

Reformat a code segment based on the style guideline?

Write an expression that uses conditional operator based on a given if statement?

Write a switch statement based on an if statement or vice versa?

Write a for statement based on a while statement or vice versa?

Explanation / Answer

1)Given an identifier, decide whether it is a legal one?

to check whether identifier is legal or not, for that we have rules

to write identifier we must use from the following fomat only

A....Z

0-9

a-z

  _ $

> identifer should not start with digit

2)Write a switch statement based on an if statement or vice versa?

Write a for statement based on a while statement or vice versa?

The for statement makes a common type of while loop easier to write. Many while loops have the general form:

For example, consider this example, copied from an example in Section 3.2:

This loop can be written as the following equivalent for statement: