• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

Java Interview Questions Answers

Question - 161 : - What restrictions are placed on method overriding?

Answer - 161 : - Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides. The overriding method may not throw any exceptions that may not be thrown by the overridden method.

Question - 162 : - What is a Java package and how is it used?

Answer - 162 : - A Java package is a naming context for classes and interfaces. A package is used to create a separate name space for groups of classes and interfaces. Packages are also used to organize related classes and interfaces into a single API unit and to control accessibility to these classes and interfaces.

Question - 163 : - Why do we need to use getSystemResource() and getSystemResources() method to load resources?

Answer - 163 : - Because we want to look for resources strictly from the system classpath, These methods use the system ClassLoader to locate resources, which gives you stricter control of the resources used by the application.

Question - 164 : - What would you use to compare two String variables - the operator == or the method equals()?

Answer - 164 : - I'd use the method equals() to compare the values of the Strings and the == to check if two variables point at the same instance of a String object.

Question - 165 : - What class allows you to read objects directly from a stream?

Answer - 165 : - The ObjectInputStream class supports the reading of objects from input streams.

Question - 166 : - What is the difference between the paint() and repaint() methods?

Answer - 166 : - 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.

Question - 167 : - How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?

Answer - 167 : - Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.

Question - 168 : - How do you restrict a user to cut and paste from the html page?

Answer - 168 : - Using Servlet or client side scripts to lock keyboard keys. It is one of solutions.

Question - 169 : - What is the benefit of subclass?

Answer - 169 : - Generally: The sub class inherits all the public methods and the implementation. The sub class inherits all the protected methods and their implementation. The sub class inherits all the default(non-access modifier) methods and their implementation. The sub class also inherits all the public, protected and default member variables from the super class. The constructors are not part of this inheritance model.

Question - 170 : - What is the difference between preemptive scheduling and time slicing?

Answer - 170 : - Under preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. Under time slicing, a task executes for a predefined slice of time and then reenters the pool of ready tasks. The scheduler then determines which task should execute next, based on priority and other factors.

Computer Contributors

Rajeev Katiyar
Yes Baroda

Share your email for latest updates


Our partners