Core Java Interview Questions – Set 02

If a variable is declared as private, where may the variable be accessed

A private variable may only be accessed within the class in which it is declared.

Name the eight primitive Java types.

The eight primitive types are byte, char, short, int, long, float, double, and boolean.

Name three subclasses of the Component class

Box.Filler, Button, Canvas, Checkbox, Choice, Container, Label, List, Scrollbar, or TextComponent.

How are this and super used

this is used to refer to the current object instance.

super is used to refer to the variables and methods of the superclass of the current object instance.

What are the rules for overriding

Private method can be overridden by private, friendly, protected or public

methods. Friendly method can be overridden by friendly, protected or public methods.

Protected method can be overridden by protected or public methods. Public method

can be overridden by public method

What is the difference between a Window and a Frame

The Frame class extends Window to define a main application window that can have a menu bar

What is a layout manager

A layout manager is an object that is used to organize components in a container.

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

What is the difference between a field variable and a local variable

A field variable is a variable that is declared as a member of a class.

A local variable is a variable that is declared local to a method.

method is used to specify a container’s layout?

The setLayout() method is used to specify a container’s layout.