Lec 4 Characters and Strings Flashcards
char letter = ‘A’
What type of char is letter?
ASCII
char numChar = ‘4’
what type of char is this?
ASCII
char letter = ‘\u0041’
what type of char is letter?
unicode char
True or False: A java character is stored in 2 bytes
True
What is the output of System.out.println(“smith\exam1\test.txt”)? Pretend there are double \’s
smith\exam1\test.txt
True or false: An int variable can hold ‘x’
True, but ‘x’ = 120
True or false: An int variable can hold ‘120’
False
What does Character.isDigit(ch) return?
Boolean
Whether or not the input is a character that holds a digit, like ‘1’ returns true, but ‘a’ returns false
What does Character.isLetter(ch) return?
Boolean
Whether or not if the character is a letter
What does Character.isLetterOrDigit(ch) return?
Boolean
Whether or not the character is a letter or digit
What does Character.isLowerCase(ch) return?
Whether the character is an uppercase
What does Character.toLowerCase(ch) return?
the lowercase character
What does str.toUpperCase() return?
the uppercase version of str
What does str.charAt(index) return?
the char at the index of str
What does str.concat(“s1”) return?
the concatenated version of str and “s1”
what does str.toUpperCase() return?
the all capitalized version of str
What does trim() return?
the string without any whitespaces on both sides
What is the difference between instance and static methods?
instance methods can only be invoked from a specific string method while a static method is a non-instance method and can be invoked without using an object
What is the syntax to invoke a static method?
Classname.methodname(args)
True or False: Character.toUpperCase(c) is a static method
False. The method is called on an obj and is therefore an instance method
True of False: Math.sin(2) is an instance method
False. All Math methods are static methods and don’t use an obj
Unicode for “A” is 65. What does “A” + 1 equal?
“A1”
Unicode for ‘A’ is 65. What does ‘A’ + 1 equal?
66
How to uppercase all characters in “java”?
“java”.toUpperCase()