Inside the Briefcase

Augmented Reality Analytics: Transforming Data Visualization

Augmented Reality Analytics: Transforming Data Visualization

Tweet Augmented reality is transforming how data is visualized...

ITBriefcase.net Membership!

ITBriefcase.net Membership!

Tweet Register as an ITBriefcase.net member to unlock exclusive...

Women in Tech Boston

Women in Tech Boston

Hear from an industry analyst and a Fortinet customer...

IT Briefcase Interview: Simplicity, Security, and Scale – The Future for MSPs

IT Briefcase Interview: Simplicity, Security, and Scale – The Future for MSPs

In this interview, JumpCloud’s Antoine Jebara, co-founder and GM...

Tips And Tricks On Getting The Most Out of VPN Services

Tips And Tricks On Getting The Most Out of VPN Services

In the wake of restrictions in access to certain...

7 Uncommon Interview Questions for Java Developers

May 22, 2017 No Comments

Featured article by Levy Williamson, Independent Technology Author

lap top

Are you preparing for a Java interview? This post discusses some of the core interview questions employers often throw at their prospected associates. Before you can be considered for a top Java programming job, recruiters will test your depth of knowledge in both object-oriented programming and structured Java. These queries can be plucked from any core Java topic. Therefore, we have collected a wide range of technical issues in Java that are likely to be tested.

How do you check if String contains PHP substring?

You can use two methods for checking if a PHP string contains another string. The first option involves the use of strops PHP function. consider this example:

<?php
$pos =
strops ($groceries,$cabbage);
if ($pos ===false) {
//this implies that cabbage is NOT found in the groceries
}
else {
//this implies that cabbage is found in the groceries
}
?>

The second option involves the use of stristr() function. It is a better approach because it is not only faster but also uses little memory.

In garbage collectors, what is structure java heap?

The purpose of garbage collection in Java is to identify and get rid of objects that are no longer essential for the application. The resources used initially by the garbage is therefore reclaimed and reused. In garbage collection, JVM has a heap, which is the runtime data area that stores memory for all the class instances and arrays. The heap is created when you start the JVM. Memory is reclaimed through an automatic memory management system referred to as a garbage collector.

Heap memory may contain either live or dead objects. The former are accessible by the application and do not form part of the garbage. Dead objects, on the other hand, are not accessible by the application and are usually awaiting garbage collection. They, however, occupy a valuable portion of the Heap memory until they are cleaned.

What are the two forms of exception handling in Java?

Java has two types of exception handling; checked and unchecked. An unchecked exception doesn’t have to be declared by either a constructor’s throws clause or a method. That is the case if they can be thrown by the implementation of a method or a constructor to operate outside the method or constructor parentheses. The checked exceptions, on the other hand, have to be declared in a method or within a constructor’s throws clause.

Describe and differentiate between fail-fast and fail-safe iterators with examples

The main point of difference between fail-fast and fail-safe iterators is whether or not the collection can be changed as it is under iteration. Fail-fast iterators work directly on the collection operation. When the iteration is underway, fail-fast iterators malfunction the moment they register a modification in the collection. This may be caused by the addition of a member, its modification, or removal. They will throw a “ConcurrentModificationException.” Examples include HashSet, ArrayList, and HashMap.

Fail-safe iterators on the other hand work on a clone of the collection. Hence, they do not throw an exception if a change occurs to the collection during the iteration. Example are the iterators returned by ConcurrentHashMap as well as CopyOnWriteArrayList.

Why is it more secure to store sensitive information such as SSN or passwords in a character array instead of a String?

When programming in Java, Strings are considered immutable. They reside in the String pool upon their declaration until they are collected as garbage. This implies that after you finish processing a string value, it remains available in the heap memory for an indeterminate period which you have no control over. Therefore, a hacker or anyone with access to the memory dump has the potential of extracting the sensitive data and use it for malicious intent.

If you use mutable objects like a character array to store a variable, for instance, you can evade this risk. Mutable variables can be set to blank immediately you are done with its operation. This way, you will save the heap space.

What is ThreadLocal class, and how would you use it?

A ThreadLocal class can store multiple values for every thread independently in a single instance. Therefore, every thread that calls the get() or set() method of a ThreadLocal instance accesses its own copy of the variable initialized independently. ThreadLocal instances can be regarded as private static fields in a class seeking to associate with a particular thread. Examples of such instances are a User ID or Student registration number.

Every thread carries an implicit reference to its clone of a thread-local variable. This happens as long as the thread is active and the ThreadLocal instance is reachable. When you disregard a thread, the copies of the thread-local instances are dumped through garbage collection.

Differentiate between function overriding and overloading in Java

Function overriding and overloading are fundamental concepts of object-oriented programming. An override is a function that takes place in a class that inherits from another one. It replaces a function inherited from the base class in a manner that the function can still be called when an instance of its class changes through polymorphism.

Overloading, on the other hand, refers to defining several methods with the same name while using different parameters. It is not associated with either overriding or polymorphism. The two primary forms of overloading include varying the number of arguments and varying the data type.

These are some of the uncommon Java interview questions that can prepare you for your dream job. Add them to your to-do list before approaching any technical Java interview.

 

Leave a Reply

(required)

(required)


ADVERTISEMENT

Gartner

WomeninTech