COMP1AL Final Notes
COMP1AL Final Notes
Java Keywords
Keyword type
Primitive types
Access modifiers
Special modifiers
Control flow
OOP specific
Keywords
boolean, byte, char, double, float, int, long, short
public, private, protected
abstract, final, native, static, strictfp, synchronized,
transient, volatile
if, else, do, while, switch, case, default, for, break,
continue
class, extends, implements, import, instanceof, interface,
new, package, super, this
+ ++
-~
!
*
/
%
+ +
<< >> >>>
> < >= <=
== !=
& ^ |
&& ||
?:
=
+= -= *= /= &= |=
^= %= <<= >>= >>>=
boolean type
boolean
range of values
byte: -128 to 127 inclusive
short: -32768 to 32767 inclusive
int: -2147483648 to 2147483647 inclusive
long: -9223372036854775808 to 9223372036854775807 inclusive
char: '\u0000' to '\uffff' inclusive, i.e., from 0 to 65535
float and double, floating-point values as defined in the single-precision 32-bit and double
precision 64-bit IEEE 754 standard
boolean, logical values
length()
Returns the length of this string.
toLowerCase()
Converts all of the characters in this String to lower case using the rules of the default locale.
toUpperCase()
Converts all of the characters in this String to upper case using the rules of the default locale.
Character Methods
isLetter()
Determines whether the specified char value is a letter.
isDigit()
Determines whether the specified char value is a digit.
toUpperCase()
Returns the uppercase form of the specified char value.
toLowerCase()
Returns the lowercase form of the specified char value.
toString()
Returns a String object representing the specified character value that is, a one-character string.
No Vowels
Write a Java program that accepts a string value as input and then prints out the input string with the vowels removed.
Sample Output:
Palindrome: Yes
Palindrome: No
Reverse Value: Greater
Palindrome: No
Reverse Value: Less
}
Vowels and others
Write a Java program which accepts as input a character value, and then determines if the input character is a digit, a
vowel, or a consonant character. Assume that only such characters are inputted, and that, for alphabetic characters,
the input is in lowercase.
Sample Output:
Input Character: 6
Input Character: k
Input Character: u
Character is a DIGIT.
Character is a
CONSONANT.
Character is a VOWEL.