Core Java Interview Questions – Set 10

What methods are used to get and set the text label displayed by a Button object?

getLabel() and setLabel().

What is the difference between choice and list?

?– A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices and only one item may be selected from a choice. A List may be displayed in such a way that several list items are visible and it supports the selection of one or more list items.

What are wrapper classes?-

?– Wrapper classes are classes that allow primitive types to be accessed as objects.

What is JIT (Just-in-Time) Compilation?

When JVM compiles the class file he does not compile the full class file in one shot. Compilation is done on function basis or file basis. Advantage gained from this is that heavy parsing of original source code is avoided. Depending on need basis the compilation is done. This typ of compilation is termed as JIT or Just-in- Time compilation.

What is the difference between this() and super()?

this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor.

What are order of precedence and associativity, and how are they used

Order of precedence determines the order in which operators are evaluated in expressions.

Associatity determines whether an expression is evaluated left-to-right or right-to-left.

How to create a immutable object in Java? Does all property of immutable object needs to be final?

To create a object immutable You need to make the class final and all its member final so that once objects gets crated no one can modify its state. You can achieve same functionality by making member as non final but private and not modifying them except in constructor. Also its NOT necessary to have all the properties final since you can achieve same functionality by making member as non final but private and not modifying them except in constructor.

What is the difference between String and String Buffer

?– a) String objects are constants and immutable whereas StringBuffer objects are not. b) String class supports constant strings whereas StringBuffer class supports growable and modifiable strings.

Which class is the immediate superclass of the MenuComponent class

Object.

Which TextComponent method is used to set a TextComponent to the read-only state

setEditable().