• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 121 : - Can a private method of a superclass be declared within a subclass?

Answer - 121 : - Sure. A private field or method or inner class belongs to its declared class and hides from its subclasses. There is no way for private stuff to have a runtime overloading or overriding (polymorphism) features.

Question - 122 : - Can each Java object keep track of all the threads that want to exclusively access to it?

Answer - 122 : - Yes. Use Thread.currentThread() method to track the accessing thread.

Question - 123 : - When a thread is created and started, what is its initial state?

Answer - 123 : - A thread is in the ready state after it has been created and started.

Question - 124 : - How are Observer and Observable used?

Answer - 124 : - Objects that subclass the Observable class maintain a list of observers. When an Observable object is updated, it invokes the update() method of each of its observers to notify the observers that it has changed state. The Observer interface is implemented by objects that observe Observable objects.

Question - 125 : - How the object oriented approach helps us keep complexity of software development under control?

Answer - 125 : - We can discuss such issue from the following aspects: Objects allow procedures to be encapsulated with their data to reduce potential interference. Inheritance allows well-tested procedures to be reused and enables changes to make once and have effect in all relevant places. The well-defined separations of interface and implementation allow constraints to be imposed on inheriting classes while still allowing the flexibility of overriding and overloading.

Question - 126 : -  What is ClassDefNotFoundException and NoClassDefFoundError and explain differences between these two?

Answer - 126 : - Given a class A.. A ClassNotFoundException means that the classloader cannot load class A. A ClassDefNotFoundError means that the classloader can load class A, but cannot instantiate it because it cannot load the other classes that class A depend on.

Question - 127 : - How to define an Interface in Java ?

Answer - 127 : - In Java Interface defines the methods but does not implement them. Interface can include constants. A class that implements the interfaces is bound to implement all the methods defined in Interface. Emaple of Interface: public interface sampleInterface { public void functionOne(); public long CONSTANT_ONE = 1000; } If a class is located in a package, what do you need to change in the OS environment to be able to use it? You need to add a directory or a jar file that contains the package directories to the CLASSPATH environment variable. Let's say a class Employee belongs to a package com.xyz.hr; and is located in the file c:\dev\com\xyz\hr\Employee.java. In this case, you'd need to add c:\dev to the variable CLASSPATH. If this class contains the method main(), you could test it from a command prompt window as follows: c:\>java com.xyz.hr.Employee

Question - 128 : - What method is used to specify a container's layout?

Answer - 128 : - The setLayout() method is used to specify a container's layout.

Question - 129 : - When can an object reference be cast to an interface reference?

Answer - 129 : - An object reference can be cast to an interface reference when the object implements the referenced interface.

Question - 130 : - What kind of security tools are available in J2SE 5.0?

Answer - 130 : - There are three tools that can be used to protect application working within the scope of security policies set at remote sites. keytool -- used to manage keystores and certificates. jarsigner -- used to generate and verify JAR signatures. policytool -- used for managing policy files. There are three tools that help obtain, list and manage Kerberos tickets. kinit -- used to obtain Kerberos V5 tickets. tklist -- used to list entries in credential cache and key tab. ktab -- used to help manage entries in the key table.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners