Imp questions and answers for chapter 10th and 11t


  1. By which of the following operators are instance variables and instance methods accessed?
    • (A) .
    • (B) new
    • (C) ;
    • (D) Dot Operator
      Answer: Dot Operator
  2. What have the designers of Java already provided with class methods?
    • (A) Built-in class
    • (B) Built-in operator
    • (C) Built-in function
    • (D) All of these
      Answer: Built-in class
  3. Which of the following variables belong to each object?
    • (A) Instance
    • (B) Method
    • (C) Class
    • (D) None of these
      Answer: Instance
  4. Which of the following refers to more than one method having the same name but different parameters?
    • (A) Overloaded methods
    • (B) Overridden methods
    • (C) Duplicate methods
    • (D) All of the above
      Answer: Overridden methods
  5. ………. type of relationship between two classes is created in composition and aggregation.
    • (A) has-a
    • (B) have-a
    • (C) is-a
    • (D) None of these
      Answer: has-a
  6. Which of the following is the keyword used to refer to a superclass constructor in a subclass constructor?
    • (A) extends
    • (B) super
    • (C) Name of the superclass
    • (D) new
      Answer: super
  7. Which is the keyword used to create an object?
    • (A) Class
    • (B) Obj
    • (C) new
    • (D) New
      Answer: new
  8. Which of the following has its own set of data?
    • (A) Object
    • (B) Class
    • (C) Method
    • (D) Super classes
      Answer: Object
  9. What does the class define?
    • (A) Kind of attributes
    • (B) Name of attributes
    • (C) Both A and B
    • (D) None of these
      Answer: Kind of attributes
  10. Which of the following is used to represent a two-dimensional data structure like a table of rows and columns?
    • (A) Vector
    • (B) Matrix
    • (C) String
    • (D) Map
      Answer: Matrix
  11. If str is the object of the String class and its content is “Thank GOD”, then what is the value of str.length()?
    • (A) 9
    • (B) 10
    • (C) 8
    • (D) 11
      Answer: 9
  12. Arrays can represent ……….. data.
    • (A) Vector
    • (B) Matrix
    • (C) Multi-dimensional
    • (D) All of these
      Answer: All of these
  13. ………….. subclass of the Calendar class is used in our syllabus.
    • (A) GeoCalendar
    • (B) GregorianCalendar
    • (C) StandardCalendar
    • (D) MainCalendar
      Answer: GregorianCalendar
  14. How many bytes does an Integer of int data type use for storage space?
    • (A) 4
    • (B) 1
    • (C) 2
    • (D) 3
      Answer: 4
  15. What does the sort method sort when we use only an array as an argument?
    • (A) An entire part of an array
    • (B) Last ten elements of an array
    • (C) First ten elements of an array
    • (D) Partial array
      Answer: An entire part of an array
  16. How many pairs of square brackets are used to declare a 2-D array in Java?
    • (A) Three
    • (B) Two
    • (C) Four
    • (D) One
      Answer: Two
  17. By which of the following pairs of braces is each row initialized by enclosing its elements separated by commas for a 2-D array?
    • (A) { }
    • (B) [ ]
    • (C) ( )
    • (D) " "
      Answer: { }
  18. By using which method of the String class can we determine the length of a string?
    • (A) length()
    • (B) Len()
    • (C) CharLength()
    • (D) Length()
      Answer: length()
  19. Which is the code where we want to monitor for exceptions?
    • (A) try
    • (B) catch
    • (C) finally
    • (D) throw
      Answer: try
  20. In which of the following brackets is the code that is to be executed to handle an exception written?
    • (A) { }
    • (B) ( )
    • (C) < >
    • (D) [ ]
      Answer: { }
  21. Which of the following if statements is true to check whether the value of variable m is from 0 to 100 or not?
    • (A) if (m < 0 || m > 100)
    • (B) if (m < 0) || (m > 100)
    • (C) if (m < 0 || > 100)
    • (D) if {m < 10 || m > 100}
      Answer: if (m < 0 || m > 100)
  22. Which of the following is a text editor?
    • (A) vi
    • (B) SciTE
    • (C) Both A and B
    • (D) gimp
      Answer: Both A and B
  23. Which of the following is a checked exception, so that we must take care of it?
    • (A) IOException
    • (B) MismatchException
    • (C) ErrorException
    • (D) TypeException
      Answer: IOException
  24. Which method of the FileReader class is used to read data from the file?
    • (A) scan()
    • (B) input()
    • (C) read()
    • (D) free()
      Answer: read()
  25. Which of the following is a subclass of InputStream?
    • (A) FileInputStream
    • (B) Input
    • (C) Stream
    • (D) FileInput
      Answer: FileInputStream

Question 26.
The instructions having possibilities to have errors are written in …………. .
(A) try
(B) catch
(C) finally
(D) throw
Answer:
(A) try

Question 27.
……………. block should be there after try block.
(A) catch
(B) finally
(C) throw
(D) (A) or (B)
Answer:
(D) (A) or (B)

Question 28.
Catch block must be ……………. .
(A) before try block
(B) after try block
(C) at the end of program
(D) after finally block
Answer:
(B) after try block

Question 29.
…………… is the exception handler.
(A) Try block
(B) Catch block
(C) Finally block
(D) All of these
Answer:
(B) Catch block

Question 30.
……………… is the reason that catch block is called exception handler.
(A) Catch block handles the exception
(B) Catch block is the main block
(C) Program is not possible without catch block
(D) All of these
Answer:
(A) Catch block handles the exception

Question 31.
…………… catch blocks can be there form one try block.
(A) Only one
(B) One or more
(C) 2
(D) As many try blocks that many catch blocks
Answer:
(B) One or more

Question 32.
…………. is incorrect for catch block.
(A) One parameter is given after the keyword catch
(B) Instructions for exceptions handling are written in braces
(C) If there are more than one exception then also one catch block is enough
(D) Finally block must be before catch block
Answer:
(C) If there are more than one exception then also one catch block is enough

Question 33.
……………. block creates ‘eobj’ object.
(A) Try block
(B) Catch block
(C) Finally block
(D) All of these
Answer:
(A) Try block

Question 34.
……………… holds the indication of ‘eobj’ object.
(A) Try block
(B) Catch block
(C) Finally block
(D) All of these
Answer:
(B) Catch block

Question 35.
What is the use of catch block ?
(A) To handle the exceptions
(B) It does not allow the program to terminate unexpectedly
(C) (A) and (B) both
(D) Helpful in terminating the program
Answer:
(C) (A) and (B) both

Question 36.
The possibilities of arising exceptions are written in …………… .
(A) catch
(B) try
(C) finally
(C) throw
Answer:
(B) try

Question 37.
When more catch blocks are possible ?
(A) If there are more than one exception occurred in try block
(B) To make program easier
(C) If there is a possibility to have an error in the program
(D) This is not possible
Answer:
(A) If there are more than one exception occurred in try block

Question 38.
…………….. block can throw different exceptions.
(A) The try block
(B) The catch block
(C) The finally block
(D) All of these
Answer:
(A) The try block

Question 39.
Is it necessary to make separate catch block for each type of exception ?
(A) Yes
(B) No
(C) This is not possible
(D) It is dependent on the program
Answer:
(A) Yes

Question 40.
Where is the block for default type catch division in the program ?
(A) After first catch block
(B) Last catch block
(C) At the end of the program
(D) This is not possible
Answer:
(B) Last catch block

Question 41.
…………… block handles the exceptions in Java program.
(A) The catch block
(B) Default type catch block
(C) The finally block
(D) The throw block
Answer:
(B) Default type catch block

Question 42.
What is the use of finally block ?
(A) To terminate the program
(B) To clean up at the end after executing try block
(C) To make sure that some specific instructions are to be executed
(D) (B) and (C) both
Answer:
(D) (B) and (C) both

Question 43.
Finally block does not care about ……………. .
(A) whether the exceptions are thrown or not by try block
(B) inside catch block
(C) (A) and (B) both
(D) none of these
Answer:
(A) whether the exceptions are thrown or not by try block

Question 44.
……………. is incorrect about finally block.
(A) If it is necessary to close the file after executing the program
(B) It is always at the end of the program
(C) [ ] bracket is used in creating finally block
(D) If any resources are to be released at that time it is widely used
Answer:
(C) [ ] bracket is used in creating finally block

Question 45.
What is the location of finally in java program ?
(A) If the beginning of program
(B) If catch block is not there then after try block
(C) If there is catch block then after try block and catch block
(D) (A) or (B)
Answer:
(D) (A) or (B)

Question 46.
If finally or catch are not given at the perfect location then ……………. can happen.
(A) program get compiled
(B) program does not compile
(C) program is terminated immediately
(D) program enters the loop
Answer:
(B) program does not compile

Question 47.
What is the use of throw keyword ?
(A) To move necessary statements
(B) To throw the object of an exception
(C) To exit the program
(D) To take the control of the program in the beginning
Answer:
(B) To throw the object of an exception

Question 48.
Arithmetic exception is thrown using …………. .
(A) throw keyword
(B) with try block
(C) using JVM
(D) throws statement
Answer:
(C) using JVM

Question 49.
Object which is thrown using throws keyword must be of …………….. type.
(A) java.lang.throwable
(B) java.lang.string
(C) java.lang.scanner
(D) Java.lang.throw
Answer:
(A) java.lang.throwable

Question 50.
………….. is the syntax to throw the exceptions object.
(A) Throw. exception_object;
(B) Throw exception_object
(C) Throw exception_object;
(D) Throw exception_object;
Answer:
(C) Throw exception_object;

Question 51.
Java provides the classes for different type of Input/Output (I/O) processes to be done on ………………. .
(A) bytes
(B) characters
(C) (A) and (B) both
(D) none of these
Answer:
(C) (A) and (B) both

Question 52.
I/O stands for …………… .
(A) inline/outline
(B) input/output
(C) in/out
(D) inner/outer
Answer:
(B) input/output

Question 53.
How many classes are provided by Java to process on bytes and characters ?
(A) Two
(B) Three
(C) Four
(D) Five
Answer:
(A) Two

Question 54.
Java provides …………… to process on bytes and characters for input/output.
(A) to read data from file
(B) to write data in a file
(C) (A) and (B) both
(D) none of these
Answer:
(C) (A) and (B) both

Question 55.
Which class includes the characteristics of file or directory ?
(A) java.io.File
(B) java.class.File
(C) java.attributes.File
(D) java.File.Directory
Answer:
(A) java.io.File

Question 56.
To achieve ……………….. file class is used.
(A) file attributes
(B) directory attributes
(C) (A) and (B) both
(D) none of these
Answer:
(C) (A) and (B) both

Question 57.
……………… process can be done on file or directory.
(A) Create
(B) Rename
(C) Delete
(D) All of these
Answer:
(D) All of these

Question 58.
Information of …………………. type can be achieved for the attributes of files.
(A) to use the file
(B) size of a file
(C) time of last modification
(D) all of these
Answer:
(D) all of these

Question 59.
The meaning of creating a file object related to file class is not that ……………. .
(A) the file or directory exists
(B) the file or directory does not exist
(C) (A) and (B) both
(D) none of these.
Answer:
(A) the file or directory exists

Question 60.
How many methods are there to process on file or directory ?
(A) 20
(B) 30
(C) 40
(D) 50
Answer:
(B) 30

Question 61.
For ……………. process file class does not provide any method.
(A) to read from a file
(B) to write in a file
(C) (A) and (B) both
(D) none of these
Answer:
(C) (A) and (B) both

Question 62.
……………… class is available to read or write in a file.
(A) Stream class
(B) Master class
(C) User class
(D) Process class
Answer:
(A) Stream class

Question 63.
Using file class …………………. type of reference can be given for a file.
(A) giving related path
(B) giving absolute path
(C) (A) or (B)
(D) none of these
Answer:
(C) (A) or (B)

Question 64.
To make a file or directory, ……………… constructor is provided by class.
(A) file (string path)
(B) file (string directory_path, string file_name)
(C) file (file directory, string file_name)
(D) all of these
Answer:
(D) all of these

Question 65.
The “passwd” file of ………………… directory of Linux stores the information of user.
(A) /etc
(B) /root
(C) /bin
(D) /home
Answer:
(A) /etc

Question 66.
The ………………. file of /etc directory of Linux stores the information of user.
(A) pass
(B) passwr
(C) passwd
(D) password
Answer:
(C) passwd

Question 67.
To indicate the attributes of the file which – method is used to create Java file object ?
(A) Indicating the path
(B) By indicating the directory and file with different arguments
(C) Giving the reference of directory lying in dirobj object.
(D) All of these
Answer:
(D) All of these

Question 68.
Which method shows the method to create java file object ?
(A) File dirobj = new File (“etc”); File fileobj = new File (dirobj, “passwd”);
(B) File fileobj = new File (“etc”, “passwd”);
(C) File fileobj = new File (“etc/passwd”);
(D) Any of these
Answer:
(C) File fileobj = new File (“etc/passwd”);

Question 69.
Which option shows the method of file class ?
(A) boolean exists(), boolean isFile()
(B) boolean isDirectory(), boolean isHidden()
(C) String getAbsolutePath(), String getName
(D) All of these
OR
(A) String getPath()
(B) long length()
(C) String [ ] list(), File [ ] listFiles[ ]
(D) All of these
Answer:
(D) All of these

Question 70.
Which method of file class returns true or false if the file or directory exists or not ?
(A) boolean isDirectory()
(B) boolean isFile()
(C) boolean exists()
(D) boolean isHidden()
Answer:
(C) boolean exists()

Question 71.
Which value is returned by the method boolean existsO ?
(A) true
(B) false
(C) (A) or (B)
(D) None of these
Answer:
(C) (A) or (B)

Question 72.
Which method returns true if the file exists otherwise returns false ?
(A) boolean isDirectory()
(B) boolean isFile()
(C) boolean exists()
(D) boolean is Hidden()
Answer:
(B) boolean isFile()

Question 73.
boolean isFile() can return ……………… value.
(A) true
(B) false
(C) (A) or (B)
(D) None of these
Answer:
(C) (A) or (B)

Question 74.
Which method returns true if the directory exists otherwise returns false ?
(A) boolean is Directory()
(B) boolean isFile()
(C) boolean exists()
(D) boolean isHidden()
Answer:
(A) boolean is Directory()

Question 75.
boolean isDirectory() can return ……………… value.
(A) true
(B) false
(C) (A) or (B)
(D) None of these
Answer:
(C) (A) or (B)

Question 76.
Which method returns true if the file is hidden ?
(A) boolean isDirectory()
(B) boolean isFile()
(C) boolean exists()
(D) boolean isHidden()
Answer:
(D) boolean isHidden()

Question 77.
boolean isHidden() method returns ……………….. if file or directory is hidden.
(A) tme
(B) false
(C) hidden
(D) hide
Answer:
(A) tme

Question 78.
Which method returns the Absolute path of a file ?
(A) Long length ()
(B) String getPath()
(C) String getName ()
(D) String getAbsolutePath()
Answer:
(D) String getAbsolutePath()

Question 79.
Which method of the name of file or directory referred by the object ?
(A) Long length ()
(B) String getPath()
(C) String getName()
(D) String getAbsolutePath()
Answer:
(C) String getName()

Question 80.
Which method returns the path to the file or directory ?
(A) Long length ()
(B) String getPath()
(C) String getName()
(D) String getAbsolutePath()
Answer:
(B) String getPath()

Question 81.
Which method returns the number of bytes in , the file ?
(A) Long length ()
(B) String getPath()
(C) String getName()
(D) String getAbsolutePath()
Answer:
(A) Long length ()

Question 82.
What is returned by long length!( method ?
(A) Characters in a file
(B) Words in file
(C) Bits of file
(D) Bytes of file
Answer:
(D) Bytes of file

Question 83.
Which method returns the name of the files and directories in directory ?
(A) String[ ] list()
(B) File[ ] listFiles()
(C) String() list[ ]
(D) File() listFiles[ ]
Answer:
(A) String[ ] list()

Question 84.
What is returned by String! ] list!) method ?
(A) File names available in a directory
(B) Directory names available in a directory
(C) (A) and (B) both
(D) None of these
Answer:
(C) (A) and (B) both

Question 85.
Which method returns an array of abstract pathnames denoting the files in the directory ?
(A) String[ ] list( )
(B) File[ ] listFiles( )
(C) String( ) list[ ]
(D) File( ) listFiles[ ]
Answer:
(B) File[ ] listFiles( )

Question 86.
………………… can return the list file files and directories of a specified directory.
(A) list()
(B) object()
(C) class()
(D) files()
Answer:
(A) list()

Question 87.
……………… can be used to get the result available in the directory.
(A) According path
(B) Names of files
(C) (A) and (B) both
(D) None of these
Answer:
(C) (A) and (B) both

Question 88.
To edit the file or display the content of a file, knowledge of ……………….. is important.
(A) stroke
(B) stream
(C) editor
(D) application
Answer:
(B) stream

Question 89.
For ………………., stream class is used.
(A) to write in a file
(B) to read a file from file
(C) (A) and (B) both
(D) none of these
Answer:
(C) (A) and (B) both

Question 90.
Keyboard is a ……………… type of device.
(A) input
(B) output
(C) input/output
(D) storage
Answer:
(A) input

Question 91.
Monitor is a ……………… type of device.
(A) input
(B) output
(C) input/output
(D) storage
Answer:
(B) output

Question 92.
Hard disk is a ……………… type of device.
(A) input
(B) output
(C) input/output
(D) storage
Answer:
(C) input/output

Question 93.
Due to ……………., hard disk is considered as input and output both devices.
(A) data can be read from the hard disk.
(B) data can be written in a hard disk.
(C) (A) and (B) both
(D) none of these.
Answer:
(C) (A) and (B) both

Question 94.
……………. can be different with the harddisks.
(A) Manufacturer
(B) Storage
(C) Connection
(D) All of these
Answer:
(D) All of these

Question 95.
………….. is not a concern for the programmer related to the hard disk.
(A) Due to process of file provided by Java.
(B) Due to process of stream provided by Java.
(C) Due to process of connections provided by Java.
(D) Due to process of path provided by Java.
Answer:
(B) Due to process of stream provided by Java.

Question 96.
………….. is an abstract representation of an input or output device that is used as source or destination of data.
(A) Stream
(B) Class
(C) Path
(D) String
Answer:
(A) Stream

Question 97.
We can visualize a stream of program as ………………. .
(A) a sequence of bytes that flows into the program
(B) a sequence of bytes that flows out of the program
(C) (A) or (B)
(D) none of these
Answer:
(C) (A) or (B)

Question 98.
What can be done using a stream ?
(A) Data can be written
(B) Data can be read
(C) (A) and (B) both
(D) None of these
Answer:
(C) (A) and (B) both

Question 99.
Which sentence is true for the stream ?
(1) It is an abstract representation of an input or output device.
(2) It is a sequence of bytes that flows into the program or out of the program.
(3) Read or write process can be done using a stream.
(4) Process stream and storage stream are the types of stream.
(A) 1, 3, 4
(B) 1, 2, 4
(C) 2, 3, 4
(D) 1, 2, 3
Answer:
(D) 1, 2, 3

Question 100.
The process of writing a data through stream is called ………………. .
(A) output stream
(B) input stream
(C) process stream
(D) storage stream
Answer:
(A) output stream

Leave a Reply

Your email address will not be published. Required fields are marked *