Java Basic Programs for Beginners
Java Basic Programs for Beginners - Important Points
1. | Which of the following is a valid Java identifier? |
---|
A. 1foo
B. _foo
C. fo_o
D. #foo
View Answer Discuss Work SpaceAnswer: option b
Explanation:
Java identifiers can start with a letter, underscore, or currency symbol, and can contain letters, digits, underscores, or currency symbols.
2. | What is the output of the following program? public class Main { |
---|
A. 10
B. 12
C. 14
D. 16
View Answer Discuss Work SpaceAnswer: option b
Explanation:
3. | Which of the following is a method of the String class? |
---|
A. length()
B. size()
C. count()
D. amount()
View Answer Discuss Work SpaceAnswer: option a
Explanation:
4. | What is the output of the following program? public class Main { |
---|
A. 1 2 3 4 5
B. 5 4 3 2 1
C. 1 3 5
D. 2 4
View Answer Discuss Work SpaceAnswer: option a
Explanation:
5. | Which of the following operators has the highest precedence in Java? |
---|
A. *
B. ++
C. &&
D. +
View Answer Discuss Work SpaceAnswer: option b
Explanation: