In: Computer Science
In Java form
Answers:
// Declare and assign a char variable called myLetter to z.
char myLetter = 'z';
// Write a Java statement that makes myLetter uppercase
myLetter -= 32;
System.out.println(myLetter);
// Write a java statement that finds out if myLetter is a digit
boolean flag = Character.isDigit(myLetter);
System.out.println(myLetter + " is Character: " + flag);
// Write a java statement that finds out if myLetter is an upper case letter.
flag =Character.isUpperCase(myLetter);
System.out.println(myLetter + " is uppercase letter: " + flag);
//Assume myLetter = ‘Z’;
// What is the output for System.out.print(myLetter++);
//ans: Z.
myLetter = 'Z';
System.out.println(myLetter++);
// Assume myLetter = ‘Z’;
// What is the output for System.out.print(++myLetter);
// ans: [
myLetter = 'Z';
System.out.println(++myLetter);
// Assume myLetter = ‘Z’;
// What is the output for System.out.print(myLetter--);
// ans: Z
myLetter = 'Z';
System.out.println(myLetter--);
// What happens when a floating-point data type, like double, is cast into a char?
//ans: it narrow down the float to its integer part
myLetter = (char)66.37; //equal to myLetter = 66;
System.out.println(myLetter);
// Evaluate the following Java statement: char c = 90;
char c=90;
// What Java method in the Character class lets me know if my character is a letter?
System.out.println(Character.isLetter(c));
Java code: Main.java
public class Main{
public static void main(String []args){
// Declare and assign a char variable called myLetter to z.
char myLetter = 'z';
// Write a Java statement that makes myLetter uppercase
myLetter -= 32;
System.out.println(myLetter);
// Write a java statement that finds out if myLetter is a digit
boolean flag = Character.isDigit(myLetter);
System.out.println(myLetter + " is Character: " + flag);
// Write a java statement that finds out if myLetter is an upper case letter.
flag =Character.isUpperCase(myLetter);
System.out.println(myLetter + " is uppercase letter: " + flag);
//Assume myLetter = ‘Z’;
// What is the output for System.out.print(myLetter++);
//ans: Z.
myLetter = 'Z';
System.out.println(myLetter++);
// Assume myLetter = ‘Z’;
// What is the output for System.out.print(++myLetter);
// ans: [
myLetter = 'Z';
System.out.println(++myLetter);
// Assume myLetter = ‘Z’;
// What is the output for System.out.print(myLetter--);
// ans: Z
myLetter = 'Z';
System.out.println(myLetter--);
// What happens when a floating-point data type, like double, is cast into a char?
//ans: it narrow down the float to its integer part
myLetter = (char)66.37; //equal to myLetter = 66;
System.out.println(myLetter);
// Evaluate the following Java statement: char c = 90;
char c=90;
// What Java method in the Character class lets me know if my character is a letter?
System.out.println(Character.isLetter(c));
}
}
Output: