JAVA 9

COEP
Lets Crack Online Exam

IT Interview Exam Questions: JAVA 9 (IT Campus Placement)

Subject: JAVA 9

Part 9: List for questions and answers of JAVA

 

Q1. String is an_______

a) class

b) Variable

c) Array

d) Data type

 

Q2. Consider the following code snippet 

String river = new String(Columbia);
System.out.println(river.length());

What is printed?

a) 6

b) 7

c) 8

d) river

 

Q3. If s = “text”, what is the value returned by s.length()?

a) 4

b) 5

c) True

d) False

 

Q4. What is the difference between a TextArea and a TextField?

a) A TextArea can handle multiple lines of text

b) A textarea can be used for output

c) TextArea is not a class

d) TextAreas are used for displaying graphics

 

Q5. Which statement is true?

a) Assertions can be enabled or disabled on a class-by-class basis

b) Conditional compilation is used to allow tested classes to run at full speed

c) Assertions are appropriate for checking the validity of arguments in a method

d) The programmer can choose to execute a return statement or to throw an exception if an assertion fails

 

Q6. Given the following statement: huey.setDouble(8.0*32.2+1.0); What must be the data type of heuy?

a) Double Field

b) Text Field

c) Int field

d) Double 

 

Q7. A compound statement is:

a) A collection of one or more statements enclosed in braces

b) A statement involving if and else

c) A way of declaring variables

d) a way of setting the value of a variable

 

Q8. Which of these method of String class is used to obtain character at specified index?

a) char()

b) Charat()

c) charat()

d) charAt()

 

Q9. Which of these method of String class can be used to test to strings for equality?

a) isequal()

b) isequals()

c) equal()

d) equals()

 

Q10. Which of the following statements are incorrect?

a) String is a class

b) Strings in java are mutable

c) Every string is an object of class String

d) Java defines a peer class of String, called StringBuffer, which allows string to be altered

 

Q11. Which is a valid declarations of a String?

a) String s1 = null;

b) String s2 = ‘null’;

c) String s3 = (String) ‘abc’;

d) String s4 = (String) ‘\ufeed’;

 

Q12. Which of these method of class String is used to obtain length of String object?

a) get()

b) Sizeof()

c) lengthof()

d) length() 

 

Q13. String in Java is a?

a) class

b) object

c) variable

d) character array

 

Q14. Which of these method of String class is used to obtain character at specified index?

a) char()

b) Charat()

c) charat()

d) charAt()

 

Q15. Which of these keywords is used to refer to member of base class from a sub class?

a) upper

b) super

c) this

d) None of the mentioned

 

Q16. Which of these method of String class can be used to test to strings for equality?

a) isequal()

b) isequals()

c) equal()

d) equals()

 

Q17. Which of these method of class String is used to extract a single character from a String object?

a) CHARAT()

b) charat()

c) charAt()

d) ChatAt()

 

Q18. Which of these method of class String is used to obtain length of String object?

a) get()

b) Sizeof()

c) lengthof()

d) length() 

 

Q19. Which of these operators can be used to concatenate two or more String objects?

a) +

b) +=

c) &

d) ||

 

Q20. Which of these class is superclass of String and StringBuffer class?

a) java.util

b) java.lang

c) ArrayList

d) None of the mentioned 

 

Part 9: List for questions and answers of JAVA

 

Q1. Answer: a

 

Q2. Answer: c

 

Q3. Answer: a

 

Q4. Answer: a

 

Q5. Answer: a

 

Q6. Answer: a

 

Q7. Answer: a

 

Q8. Answer: b

 

Q9. Answer: d

 

Q10. Answer: b

 

Q11. Answer: a

 

Q12. Answer: d

 

Q13. Answer: a

 

Q14. Answer: d

 

Q15. Answer: b

 

Q16. Answer: d

 

Q17. Answer: a

 

Q18. Answer: d

 

Q19. Answer: a

 

Q20. Answer: b