Interview Preparation Exam  >  Interview Preparation Notes  >  Placement Papers - Technical & HR Questions  >  Advanced Java (Part - 2), Java Programming Interview Questions

Advanced Java (Part - 2), Java Programming Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation PDF Download

71. Can a Byte object be cast to a double value?

No. An object cannot be cast to a primitive value.

72. What is the difference between a static and a non-static inner class?

A non-static inner class may have object instances that are associated with instances of the class's outer class.

A static inner class does not have any object instances.

73. What is the difference between the String and StringBuffer classes?

String objects are constants. StringBuffer objects are not constants.

74. 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.

75. What is an object's lock and which object's have locks?

An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock.

All objects and classes have locks. A class's lock is acquired on the class's Class object.

76. What is the Dictionary class?

The Dictionary class provides the capability to store key-value pairs.

The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.

77. How are the elements of a BorderLayout organized?

The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container.

78. What is the % operator?

It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand.

79. When can an object reference be cast to an interface reference?

An object reference be cast to an interface reference when the object implements the referenced interface.

80. 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.

81. Which class is extended by all other classes?

The Object class is extended by all other classes.

82. Can an object be garbage collected while it is still reachable?

A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected..

83. Is the ternary operator written x : y ? z or x ? y : z ?

It is written x ? y : z.

84. What is the difference between the Font and FontMetrics classes?

The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.

85. How is rounding performed under integer division?

The fractional part of the result is truncated. This is known as rounding toward zero.

86. What happens when a thread cannot acquire a lock on an object?

If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available.

87. 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.

88. What classes of exceptions may be caught by a catch clause?

A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types.

89. If a class is declared without any access modifiers, where may the class be accessed?

A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.

90. What is the SimpleTimeZone class?

The SimpleTimeZone class provides support for a Gregorian calendar.

91. What is the Map interface?

The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.

92. Does a class inherit the constructors of its superclass?

A class does not inherit constructors from any of its superclasses.

93. 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 or continue statement.

94. What is the purpose of the System class?

The purpose of the System class is to provide access to system resources.

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

setEditable().

96. How are the elements of a CardLayout organized?

The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.

97. Is &&= a valid Java operator?

No. It is not a valid java operator.

98. Name the eight primitive Java types.

The eight primitive types are bytecharshortintlongfloatdouble, and boolean.

99. Which class should you use to obtain design information about an object?

The Class class is used to obtain information about an object's design.

100. What is the relationship between clipping and repainting?

When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.

101. Is "abc" a primitive value?

The String literal "abc" is not a primitive value. It is a String object.

102. What is the relationship between an event-listener interface and an event-adapter class?

An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event.

An event adapter provides a default implementation of an event-listener interface.

103. What restrictions are placed on the values of each case of a switch statement?

During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.

104. What modifiers may be used with an interface declaration?

An interface may be declared as public or abstract.

105. Is a class a subclass of itself?

A class is a subclass of itself.

106. What is the highest-level event class of the event-delegation model?

The java.util.EventObject class is the highest-level class in the event-delegation class hierarchy.

107. What event results from the clicking of a button?

The ActionEvent event is generated as the result of the clicking of a button.

108. How can a GUI component handle its own events?

A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.

109. How are the elements of a GridBagLayout organized?

The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes and may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.

110. What advantage do Java's layout managers provide over traditional windowing systems?

Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accomodate platform-specific differences among windowing systems.

111. What is the Collection interface?

The Collection interface provides support for the implementation of a mathematical bag - an unordered collection of objects that may contain duplicates.

112. What modifiers can be used with a local inner class?

A local inner class may be final or abstract.

113. What is the difference between static and non-static variables?

A static variable is associated with the class as a whole rather than with specific instances of a class.

Non-static variables take on unique values with each object instance.

114. What is the difference between the paint() and repaint() methods?

The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

115. What is the purpose of the File class?

The File class is used to create objects that provide access to the files and directories of a local file system.

116. Can an exception be rethrown?

Yes, an exception can be rethrown.

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

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

118. How does multithreading take place on a computer with a single CPU?

The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.

119. When does the compiler supply a default constructor for a class?

The compiler supplies a default constructor for a class if no other constructors are provided.

120. When is the finally clause of a try-catch-finally statement executed?

The finally clause of the try-catch-finally statement is always executed unless the thread of execution terminates or an exception occurs within the execution of the finally clause.

121. Which class is the immediate superclass of the Container class?

Component.

122. If a method is declared as protected, where may the method be accessed?

protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

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

By associating Checkbox objects with a CheckboxGroup.

124. Which non-Unicode letter characters may be used as the first character of an identifier?

The non-Unicode letter characters $ and _ may appear as the first character of an identifier

125. What restrictions are placed on method overloading?

Two methods may not have the same name and argument list but different return types.

126. What happens when you invoke a thread's interrupt method while it is sleeping or waiting?

When a task's interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown.

127. What is casting?

There are two types of casting, casting between primitive numeric types and casting between object references.

Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values.

Casting between object references is used to refer to an object by a compatible class, interface, or arraytype reference.

128. What is the return type of a program's main() method?

A program's main() method has a void return type.

129. Name four Container classes.

WindowFrameDialogFileDialogPanelApplet, or ScrollPane.

The document Advanced Java (Part - 2), Java Programming Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation is a part of the Interview Preparation Course Placement Papers - Technical & HR Questions.
All you need of Interview Preparation at this link: Interview Preparation
85 docs|57 tests

Top Courses for Interview Preparation

FAQs on Advanced Java (Part - 2), Java Programming Interview Questions - Placement Papers - Technical & HR Questions - Interview Preparation

1. What are the advanced features of Java?
Ans. Advanced features of Java include multithreading, networking, reflection, annotations, lambda expressions, and generics. These features allow programmers to write more efficient and flexible code.
2. What is the difference between checked and unchecked exceptions in Java?
Ans. Checked exceptions are exceptions that are checked at compile-time, meaning the programmer must handle or declare them in the code. On the other hand, unchecked exceptions are exceptions that are not checked at compile-time, and the programmer is not required to handle or declare them. Examples of checked exceptions are IOException and ClassNotFoundException, while examples of unchecked exceptions are NullPointerException and ArrayIndexOutOfBoundsException.
3. How does multithreading work in Java?
Ans. Multithreading in Java allows multiple threads of execution to run concurrently within a single program. Each thread represents an independent flow of control, and they can perform tasks simultaneously. Java provides built-in support for multithreading through the Thread class and the Runnable interface. By creating multiple threads, developers can take advantage of parallel processing and improve performance.
4. What is the purpose of reflection in Java?
Ans. Reflection in Java allows the program to examine and modify its own structure at runtime. It provides the ability to inspect classes, interfaces, fields, and methods dynamically, without knowing their names at compile-time. Reflection is commonly used in frameworks and libraries to implement features like dependency injection, object serialization, and dynamic proxy.
5. What are lambda expressions in Java?
Ans. Lambda expressions are a new feature introduced in Java 8 that allows the implementation of functional interfaces using a concise syntax. They provide a way to write anonymous functions or closures in Java. Lambda expressions are used extensively with Java's functional interfaces, such as the Predicate, Consumer, and Function interfaces, to enable functional programming paradigms like filtering, mapping, and reducing collections.
85 docs|57 tests
Download as PDF
Explore Courses for Interview Preparation exam

Top Courses for Interview Preparation

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Java Programming Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation

,

MCQs

,

Semester Notes

,

shortcuts and tricks

,

Previous Year Questions with Solutions

,

Advanced Java (Part - 2)

,

practice quizzes

,

Advanced Java (Part - 2)

,

Objective type Questions

,

Java Programming Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation

,

mock tests for examination

,

Important questions

,

Summary

,

Exam

,

video lectures

,

past year papers

,

Free

,

ppt

,

Extra Questions

,

pdf

,

Sample Paper

,

Java Programming Interview Questions | Placement Papers - Technical & HR Questions - Interview Preparation

,

Advanced Java (Part - 2)

,

Viva Questions

,

study material

;