Java Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Java Programming MCQ (Multiple Choice Questions)

 Que-  Which of these class contains the methods print() & println()?

a. System

b. System.out

c. BUfferedOutputStream

d. PrintStream


Answer- PrintStream


Que-  Which of these methods can be used to writing console output?

a. print()

b. println()

c. write()

d. all of the mentioned


Answer- all of the mentioned


Que-  Which of these classes are used by character streams output operations?

a. InputStream

b. Writer

c. ReadStream

d. InputOutputStream


Answer- Writer


Que-  Which of these class is used to read from a file?

a. InputStream

b. BufferedInputStream

c. FileInputStream

d. BufferedFileInputStream


Answer- FileInputStream


Que-  Which of these class contains the methods used to write in a file?

a. FileStream

b. FileInputStream

c. BUfferedOutputStream

d. FileBufferStream


Answer- FileInputStream


Que-  Which of these exception is thrown in cases when the file specified for writing is not found?

a. IOException

b. FileException

c. FileNotFoundException

d. FileInputException


Answer- FileNotFoundException


Que-  Which of these methods are used to read in from file?

a. get()

b. read()

c. scan()

d. readFileInput()


Answer- read()


Que-  Which of these values is returned by read() method is end of file (EOF) is encountered?

a.0

b.1

c.-1

d. Null


Answer--1


Que-  Which of these exception is thrown by close() and read() methods?

a. IOException

b. FileException

c. FileNotFoundException

d. FileInputOutputException


Answer- IOException


Que-  Which of these methods is used to write() into a file?

a. put()

b. putFile()

c. write()

d. writeFile()


Answer- write()


Que-  Which of these functions is called to display the output of an applet?

a. display()

b. paint()

c. displayApplet()

d. PrintApplet()


Answer- paint()


Que-  Which of these methods can be used to output a string in an applet?

a. display()

b. print()

c. drawString()

d. transient()


Answer- drawString()


Que-  Which of these methods is a part of Abstract Window Toolkit (AWT) ?

a. display()

b. paint()

c. drawString()

d. transient()


Answer- paint()


Que-  Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?

a. transient

b. volatile

c. global

d. No modifier is needed


Answer- volatile


Que-  Which of these operators can be used to get run time information about an object?

a. getInfo

b. Info

c. instanceof

d. getinfoof


Answer- instanceof


Que-  Which of these package is used for text formatting in Java programming language?

a. java.text

b. java.awt

c. java.awt.text

d. java.io


Answer- java.text


Que-  Which of this class can be used to format dates and times?

a. Date

b. SimpleDate

c. DateFormat

d. textFormat


Answer- DateFormat


Que-  Which of these method returns an instance of DateFormat that can format time information?

a. getTime()

b. getTimeInstance()

c. getTimeDateinstance()

d. getDateFormatinstance()


Answer- getTimeInstance()


Que-  Which of these class allows us to define our own formatting pattern for dates and time?

a. DefinedDateFormat

b. SimpleDateFormat

c. ComplexDateFormat

d. UsersDateFormat


Answer- SimpleDateFormat


Que-  Which of these formatting strings of SimpleDateFormat class is used to print week of the year?

a. w

b. W

c. s

d. S


Answer- w


Que-  Which of the following is not a class of java.util.regex?

a. Pattern class

b. matcher class

c. PatternSyntaxException

d. Regex class


Answer- Regex class


Que-  What is the significance of Matcher class for regular expression in java?

a. interpretes pattern in the string

b. Performs match in the string

c. interpreted both pattern and performs match operations in the string

d. None of the mentioned.


Answer- interpreted both pattern and performs match operations in the string


Que-  Object of which class is used to compile regular expression?

a. Pattern class

b. Matcher class

c. PatternSyntaxException

d. None of the mentioned


Answer- Pattern class


Que-  Which capturing group can represent the entire expression?

a. group *

b. group 0

c. group * or group 0

d. None of the mentioned


Answer- group 0


Que-  groupCount reports a total number of Capturing groups.

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-TRUE


Que-  Which of the following matches nonword character using regular expression in java?

a. \w

b. \W

c. \s

d. \S


Answer- \W


Que-  Which of the following matches end of the string using regular expression in java?

a. \z

b. \\

c. \*

d. \Z


Answer- \z


Que-  What does public int end(int group) return?

a. offset from last character of the subsequent group

b. offset from first character of the subsequent group

c. offset from last character matched

d. offset from first character matched


Answer- offset from last character of the subsequent group

Previous Post Next Post