Core Java Interview Questions – Set 06

What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy

The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

How is an argument passed in java, by copy or by reference What is a modulo operator

This operator gives the value which is related to the remainder of a divisione.g

x=7%4 gives remainder 3 as an answer

For which statements does it make sense to use a label

The only statements for which it makes sense to use a label are those statements that can enclose a break orcontinue statement.

What is the Vector class?

The Vector class provides the capability to implement a growable array of objects

What is the difference between the File and RandomAccessFile classes

The File class encapsulates the files and directories of the local file system.

The RandomAccessFile class provides the methods needed to directly access data contained in any part of a file

What happens to the bits that fall off after shifting

They are discarded

Which Math method is used to calculate the absolute value of a number

The abs() method is used to calculate absolute values.

Can you have an inner class inside a method and what variables can you access?-

?– Yes, we can have an inner class inside a method and final variables can be accessed.

How can the Checkbox class be used to create a radio button

By associating Checkbox objects with a CheckboxGroup.

What are methods and how are they defined?-

Methods are functions that operate on instances of classes in which they are defined. Objects can communicate with each other using methods and can call methods in other classes. Method definition has four parts. They are name of the method, type of object or primitive type the method returns, a list of parameters and the body of the method. A method’s signature is a combination of the first three parts mentioned above.