Java/Java Mcq Question Set 9 Sample Test,Sample questions

Question:
�Standard output variable �out� is defined in which class?

1.Process

2.Void

3.System

4.Runtime

Posted Date:-2021-10-25 05:40:10


Question:
Output : package pkg; class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.setCharAt(1, x); System.out.println(s1); } }

1.Hexlo

2.xxxxx

3.xello

4.Hxllo

Posted Date:-2021-10-25 05:40:10


Question:
What is the string contained in s after following lines of code? StringBuffer s new StringBuffer(Hello); s.deleteCharAt(0);

1.ello

2.llo

3.Hell

4.Hel

Posted Date:-2021-10-25 05:40:10


Question:
What is the value returned by function compareTo() if the invoking string is less than the string compared?

1.value less than zero

2.value greater than zero

3.zero

4.None

Posted Date:-2021-10-25 05:40:10


Question:
What is the value returned by unction compareTo() if the invoking string is less than the string compared?

1.value less than zero

2.value greater than zero

3.zero

4.None

Posted Date:-2021-10-25 05:40:10


Question:
What will s2 contain after following lines of code? String s1 = one; String s2 = s1.concat(two)

1.one

2.two

3.twoone

4.onetwo

Posted Date:-2021-10-25 05:40:10


Question:
What will s2 contain after following lines of code? StringBuffer s1 = one; StringBuffer s2 = s1.append(two)

1.one

2.two

3.twoone

4.onetwo

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following are incorrect form of StringBuffer class constructor?

1.StringBuffer(int size)

2.StringBuffer()

3.StringBuffer(int size , String str)

4.StringBuffer(String str)

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following is correct way of importing an entire package pkg?

1.Import pkg.

2.Import pkg.*

3.import pkg.

4.import pkg.*

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following is incorrect statement about packages?

1.A package can be renamed without renaming the directory in which the classes are stored.

2.Package defines a namespace in which classes are stored.

3.Java uses file system directories to store packages.

4.A package can contain other package within it.

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following is method of System class is used to find how long a program takes to execute?

1.currenttimeMillis()

2.currentTimeMillis()

3.currenttime()

4.currentTime()

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following is method of wrapper Float for converting the value of an object into byte?

1.byte bytevalue()

2.Bytevalue()

3.Byte Bytevalue()

4.bytevalue()

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following is method of wrapper Integer for converting the value of an object into byte?

1.bytevalue()

2.Byte Bytevalue()

3.Bytevalue()

4.byte bytevalue()

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following method of Process class can terminate a process?

1.void destroy()

2.void terminate()

3.void kill()

4.void exit()

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object?

1.Integer hashcode()

2.int hashCode()

3.int hashcode()

4.int hash()

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following package stores all the simple data types in java?

1.java.packages

2.util

3.lang

4.java

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following statement is correct?

1.replace() method replaces all the characters in invoking string with another character.

2.replace() replace() method replaces last occurrence of a character in invoking string with another character.

3.replace() method replaces only first occurances of a character in invoking string with another character.

4.replace() method replaces all occurrences of one character in invoking string with another character.

Posted Date:-2021-10-25 05:40:10


Question:
Which of the following statement is correct?

1.reverseall() method reverses all characters.

2.reverse() method reverses all characters.

3.replace() method replaces last occurrence of a character in invoking string with another character

4.replace() method replaces first occurrence of a character in invoking string with another character.

Posted Date:-2021-10-25 05:40:10


Question:
Which of these access specifiers can be used for a class so that it's members can be accessed by a different class in the different package?

1.Public

2.Private

3.Protected

4.None

Posted Date:-2021-10-25 05:40:10


Question:
Which of these class can encapsulate an entire executing program?

1.Process

2.Runtime

3.System

4.Void

Posted Date:-2021-10-25 05:40:10


Question:
Which of these class can generate an array which can increase and decrease in size automatically?

1.DynamicsList()

2.DynamicList()

3.ArrayList()

4.LinkedList()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these class have only one field �TYPE�?

1.Process

2.Void

3.Runtime

4.System

Posted Date:-2021-10-25 05:40:10


Question:
Which of these class holds a collection of static methods and variables?

1.System

2.Void

3.Runtime

4.Process

Posted Date:-2021-10-25 05:40:10


Question:
Which of these class is superclass of String and StringBuffer class?

1.ArrayList

2.java.lang

3.java.util

4.None

Posted Date:-2021-10-25 05:40:10


Question:
Which of these class is used to create an object whose character sequence is mutable?

1.StringBuffer()

2.String()

3.Both of the mentioned

4.None

Posted Date:-2021-10-25 05:40:10


Question:
Which of these constructors is used to create an empty String object?

1.String()

2.String(void)

3.String(0)

4.None

Posted Date:-2021-10-25 05:40:10


Question:
Which of these data type value is returned by equals() method of String class?

1.boolean

2.char

3.int

4.All of the above

Posted Date:-2021-10-25 05:40:10


Question:
Which of these is a mechanism for naming and visibility control of a class and its content?

1.Object

2.Interface

3.Packages

4.None

Posted Date:-2021-10-25 05:40:10


Question:
Which of these is a super class of wrappers Long, Character & Integer?

1.Number

2.Long

3.Float

4.Digits

Posted Date:-2021-10-25 05:40:10


Question:
Which of these is a wrapper for data type int?

1.Byte

2.Long

3.Both a & b

4.Integer

Posted Date:-2021-10-25 05:40:10


Question:
Which of these is an an correct statement?

1.StringBuffer class is used to store string in a buffer for later use.

2.String object can point to some other reference of String variable.

3.String objects are immutable, they cannot be changed.

4.None

Posted Date:-2021-10-25 05:40:10


Question:
Which of these is wrapper for simple data type char?

1.Character

2.Float

3.String

4.Both a & c

Posted Date:-2021-10-25 05:40:10


Question:
Which of these is wrapper for simple data type float?

1.Double

2.double

3.float

4.Float

Posted Date:-2021-10-25 05:40:10


Question:
Which of these keywords is used to define packages in Java?

1.Pkg

2.Package

3.package

4.pkg

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method can be used to increase the capacity of ArrayList object manually?

1.ensureCapacity()

2.increasecapacity()

3.increaseCapacity()

4.Capacity()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method of ArrayList class is used to obtain present size of an object?

1.index()

2.size()

3.capacity()

4.length()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method of class String is used to check weather a given object starts with a particular string literal?

1.Starts()

2.ends()

3.endsWith()

4.startsWith()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method of class String is used to compare two String objects for their equality?

1.Equals()

2.equals()

3.Isequal()

4.isequal()

Posted Date:-2021-10-25 05:40:10


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

1.charat()

2.charAt()

3.ChatAt()

4.CHARAT()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method of class String is used to obtain length of String object?

1.lengthof()

2.Sizeof()

3.get()

4.length()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method of class String is used to remove leading and trailing whitespaces?

1.startsWith()

2.Trim()

3.trim()

4.doTrim()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method of class StringBuffer is used to concatenate the string representation to the end of invoking string?

1.join()

2.append()

3.concat()

4.concatenate()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method of class StringBuffer is used to extract a substring from a String object

1.SubString()

2.substring()

3.Substring()

4.None

Posted Date:-2021-10-25 05:40:10


Question:
Which of these method of class StringBuffer is used to find the length of current character sequence?

1.capacity()

2.Capacity()

3.Length()

4.length()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these methods can be used to obtain a static array from an ArrayList object?

1.Array()

2.toArray()

3.covertArray()

4.covertoArray()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these methods is used to check for infinitely large and small values?

1.Isinfinite()

2.isInfinite()

3.IsNaN()

4.isNaN()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these methods is used to compare a specific region inside a string with another specific region in another string?

1.regionMatches()

2.RegionMatches()

3.regionMatch()

4.match()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these methods is used to obtain value of invoking object as a long?

1.Long longvalue()

2.long longValue()

3.Long Longvalue()

4.long value()

Posted Date:-2021-10-25 05:40:10


Question:
Which of these operators can be used to concatenate two or more String objects?

1.+

2.&

3.||

4.+=

Posted Date:-2021-10-25 05:40:10


Question:
Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?

1.Protected

2.No Modifier

3.Public

4.All of the above

Posted Date:-2021-10-25 05:40:10


More MCQS

  1. Java Mcq Question Set 1
  2. Java Mcq Question Set 2
  3. Java Mcq Question Set 3
  4. Java Mcq Question Set 4
  5. Java Mcq Question Set 5
  6. Java Mcq Question Set 6
  7. Java Mcq Question Set 7
  8. Java Mcq Question Set 8
  9. Java Mcq Question Set 9
  10. Java Multiple Choice Questions
  11. DATA TYPES IN JAVA
  12. Classes ,Constructor ,Methods,Inheritance
  13. Java Multiple Choice Questions.
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!