Question Bank
Programming with Core Java
Unit -I
- 1.
What
is the most important feature of Java?
- 2.
Explain
platform independence
- 3.
What
is a JVM? Are JVMs platform independent?
- 4.
Differentiate
between a JDK and a JVM?
- 5.
What
is a pointer? Does Java support pointers?
- 6.
What
are local variables? What are instance variables?
- 7.
In
Java, how is a constant variable defined?
- 8.
Is
it compulsory to use a main() method in all java classes?
- 9.
What
is the return type of the main() method? What is the reason behind declaring
the main() method static?
- 10.
What
is the argument of main() method?
- 11.
Can
we overload a main() method?
- 12.
Can
we declare a main() method final?
- 13.
Does
the order of public and static declaration matter in main() method?
- 14.
What
is a package? Which package is imported by default?
- 15.
Can
a class be declared as protected?
- 16.
Elaborate
the access scope of a protected method?
- 17.
Elaborate
the purpose of declaring a variable as final? Explain impact of declaring a
method as final?
- 18.
If
we do not want our class to be inherited by any other class what should we do?
- 19.
Can
you give few examples of final classes defined in Java API?
- 20.
Differentiate
final from finally and finalize()?
- 21.
Can
we declare a class as static?
- 22.
When
can a method be defined as static?
- 23.
Explain
the significance of static variable?
- 24.
Can
a static variable be declared inside a method?
- 25.
What
is the % operator?
- 26.
When
can an object reference be cast to an interface reference?
- 27.
Which
class is extended by all other classes?
- 28.
Which
non-Unicode letter characters may be used as the first character of an
identifier?
- 29.
What
are the restrictions placed on method overloading?
- 30.
What
is casting?
- 31.
What
is the return type of a program's main() method?
- 32.
Where
can the variable be accessed when it is declared as private?
- 33.
What
do you understand by private, protected and public?
- 34.
Explain
Downcasting.
- 35.
What
modifiers may be used with an inner class that is a member of an outer class?
- 36.
How
many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
- 37.
What
are the restrictions placed on the location of a package statement within a
source code file?
- 38.
What
is a native method?
- 39.
What
are order of precedence and associativity and how are they used?
- 40.
Can
an anonymous class be declared as implementing an interface and extending a
class?
- 41.
What
is the range of the char type?
- 42.
What
is the range of the short type?
- 43.
Why
doesn't operator overloading exist?
- 44.
What
does it mean when we say that a method or field is "static"?
- 45.
Is
null a keyword?
- 46.
Which
characters may be used as the second but not as the first character of an
identifier?
- 47.
Is
the ternary operator written x : y ? z or x ? y : z ?
- 48.
How
is rounding performed under integer division?
- 49.
If
a class is declared without any access modifiers, where may the class be
accessed?
- 50.
Does
a class inherit the constructors of its superclass?
- 51.
Name
the eight primitive Java types.
- 52.
What
are the restrictions that are placed on the values of each case of a switch
statement?
- 53.
Differentiate
between a while statement and a do while statement?
- 54.
What
all modifiers can be used with a local inner class?
- 55.
When
does the compiler supply a default constructor for a class?
- 56.
Where
may a method be accessed if it is declared as protected?
- 57.
Elaborate
the legal operands of the instance of operator?
- 58.
Are
true and false keywords?
- 59.
What
happens when you add a double value to a String?
- 60.
Differentiate
between inner class and nested class.
- 61.
Can
an abstract class be final?
- 62.
What
is numeric promotion?
- 63.
To
what value is a variable of the boolean type automatically initialized?
- 64.
Differentiate
between the prefix and postfix forms of the ++ operator.
- 65.
What
modifiers may be used with a top-level class?
- 66.
Differentiate
between an if statement and a switch statement?
- 67.
What
are the practical benefits, if any, of importing a specific class rather than
an entire package (e.g.import java.net.* versus import java.net.Socket)?
- 68.
Can
we overload a method based on different return type but same argument type?
- 69.
What
happens to a static variable that is defined within a method of a class?
- 70.
How
many static initializers are there?
- 71.
Differentiate
between method overriding and overloading?
- 72.
What
is constructor chaining and how is it achieved in Java?
- 73.
How
are this() and super() used with constructors?
- 74.
What
does it mean that a class or member is final?
- 75.
What
does it mean that a method or class is abstract?
Unit -II
- What is mean by OOP? Explain OOP Concepts?
- Explain in detail about Garbage Collector in Java.
- What is a Constructor? Explain types of Constructors in Java?
- Discuss about the static, final keywords with an example
- Recall Inheritance? Illustrate the types of inheritances.
- Write a java program to implement multilevel inheritance concept.
- Discuss about the super keyword in java with example.
- Compare Method Overriding and Method Overloading.
- Why interface is required?
- What is use of abstract class?
- Give the differences between Abstract class and Interface
- Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object?
- Difference between == and .equals() ?
- What are the methods of Object Class ?
- What are different ways of object creation in Java ?
- What is a cloneable interface and what all methods does it contain?
- Why do we use a copy constructor ?
- Does it make sense to clone an object which is supposed to be immutable ?
- What is a prototype design pattern ?
- Explain CloneNotSupportedException ?
- What is ArrayList in Java?
- Explain the hierarchy of ArrayList class in Java.
- Which marker interfaces are implemented by Java ArrayList?
- Which collection classes implement List interface in Java?
- What are the important features of ArrayList in Java?
- Why is ArrayList called a dynamically growing array in Java?
- How to create a generic ArrayList object in Java?
- How to add elements to Java ArrayList?
- Does ArrayList allow to insert duplicate elements?
- Is it possible to add null into ArrayList?
|
|
|
Unit -III
- Describe the difference between unchecked and checked exceptions in Java.
- What is the difference between
finally, final, and finalize in Java?
- Define try-with resource. How can
you say that it differs from an ordinary try?
- Define Runtime Exception. Describe
it with the help of an example.
- What is the difference between
NoClassDefFoundError and ClassNotFoundException in Java?
- Can we throw an exception explicitly
or manually?
- Describe the use of the throw
keyword.
- Why should we clean up activities
such as I/O resources in the finally block?
- Describe OutofMemoryError in
exception handling.
- What is the error of
ClassCastException?
- Is there any difference between
throw and throws in exception handling in Java?
- When should we use the
printStackTrace() method?
- Provide me with some examples of
unchecked exceptions.
- Is it illegal to keep an empty
catch?
- What are the advantages of using
exception handling in Java?
- Can checked exceptions occur at
compiled time?
- What happens if a runtime exception
occurs?
- Describe unreachable catch block
error in Java.
- In which situation will you not be
able to execute the finally block?
- Is it possible to throw a statement
inside a static block?
- Define rethrowing.
- Define user-defined or custom
exceptions in Java.
- What do you understand by a chained
exception?
- What do you understand about
throwables in Java?
- Mention the methods in the throwable
class.
- Give me some examples of checked
exceptions.
- Define NumberFormatException
exception in Java.
- What do you understand by
ArrayIndexOutOfBoundsException?
- Suppose there is a catch block in
tune with a try block with 3 statements - 1, 2, and 3. Now, imagine that
the statement is thrown in statement 2. Will there be an execution of
statement 3?
- Define unreachable catch block
error.
- Tell something about BufferedWriter ? What are flush() and close() used for ?
- What is Scanner class used for ? when was it introduced in Java ?
- What is a stream and what are the types of Streams and classes of the Streams?
- What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
- Which is the abstract parent class of FileWriter ?
- Which class is used to read streams of raw bytes from a file?
- Which is the Parent class of FileInputStream ?
- Which exceptions should be handled with the following code ?
- Which is the Parent Class of ByteArrayInputStream and AudioInputStream ?
- Which interfaces are implemented by InputStream?
- What is the package name for ObjectInputStream class?
- Which is the Parent Class of SequenceInputStream class?
- Which is the Parent Class of FilterInputStream class?
- What is the package name for FilterInputStream class?
- Which interfaces are implemented by FileInputStream?
- Which is the Parent Class of InputStream class?
- Which is the Parent Class of FileInputStream class?
- How do you read a file line by line in Java?
- How do you check if a file is hidden in Java?
- What is difference between getPath(), getCanonicalPath() and getAbsolutePath() in Java?
Unit
-IV
- What is the difference between Process and Thread?
- What are the benefits of multi-threaded programming?
- What is difference between user Thread and daemon Thread?
- How can we create a Thread in Java?
- What are different states in lifecycle of Thread?
- Can we call run() method of a Thread class?
- How can we pause the execution of a Thread for specific time?
- What do you understand about Thread Priority?
- What is Thread Scheduler and Time Slicing?
- What is context-switching in multi-threading?
- How can we make sure main() is the last thread to finish in Java Program?
- How does thread communicate with each other?
- Why thread communication methods wait(), notify() and notifyAll() are in Object class?
- Why wait(), notify() and notifyAll() methods have to be called from synchronized method or block?
- Why Thread sleep() and yield() methods are static?
- How can we achieve thread safety in Java?
- What is volatile keyword in Java
- Which is more preferred - Synchronized method or Synchronized block?
- How to create daemon thread in Java?
- What is ThreadLocal?
- What is Thread Group? Why it’s advised not to use it?
- What is Java Thread Dump, How can we get Java Thread dump of a Program?
- What is Deadlock? How to analyze and avoid deadlock situation?
- What is Java Timer Class? How to schedule a task to run after specific interval?
- What is Thread Pool? How can we create Thread Pool in Java?
- What will happen if we don’t override Thread class run() method?
- What is atomic operation? What are atomic classes in Java Concurrency API?
- What is Lock interface in Java Concurrency API? What are it’s benefits over synchronization?
- What is Executors Framework?
- What is BlockingQueue? How can we implement Producer-Consumer problem using Blocking Queue?
- What is Callable and Future?
- What is FutureTask class?
- What are Concurrent Collection Classes?
- What is Executors Class?
- What are some of the improvements in Concurrency API in Java 8?
- What is Generics in Java ?
- How Generics works in Java ? What is type erasure?
- What is Bounded and Unbounded wildcards in Generics?
- Can the wildcard argument be bounded?
- How to write parametrized class in Java using Generics?
- What is bounded type parameter?
- What is wildcard in Java generic?
- What Is a Generic Type Parameter?
- How Does a Generic Method Differ from a Generic Type?
- What Is Type Erasure?
Unit -V
- What is the
difference between a Swing and AWT components?
- What are the
different types of controls in AWT?
- What is clipping?
- What are the
benefits of Swing over AWT?
- What is the use of
the window class?
- What are AWT peers?
- What are the
component and container class?
- What interface is
extended by AWT event listener?
- What is paint
method? When repaint() is needed?
- List out any 10 AWT classes and their syntax.
- Discuss about Source, Event and Listeners in event handling
- Write a java program to implement Mouse Events.
- Write a java program to implement Action Events.
- Write a java program to implement Key Events.
- Difference between AWT and Swings?
No comments:
Post a Comment