Interview Questions from Core Java

Technical Questions from Core Java , Collections , Interview questions are related to use of this and super Keyword operators, JVM and Jdk, thread, Interface and access specifier, methods , class, java collections, seriazable in java , hastable , jsp servlet etc.

java is an Object  Oriented Programming Language. Which is mostly used to develop Windows based Software  as well as Web Based Project. It is good to have good knowledge about a programming language and practical knowledge for developing program in that particular language. In the technical interview for the post of  Java Developer some basic questions are asked. In this post I am telling about questions at basic level. These questions are related to use of this and super Keyword operators, JVM and Jdk, Interface and access specifier, methods , class, java collections, serializable in java , hashtable , jsp servlet etc.

Q             How are this() and super() used with constructors?  
A             this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor

Q             What is casting?  
A             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 array type reference.

Q             What is the purpose of the Runtime class?  
A             The purpose of the Runtime class is to provide access to the Java runtime system

Q             Does object serialization support encryption?  
A             Object serialization does not contain any encryption/decryption in itself. It writes to and reads from Java Streams, so it can be coupled with any available encryption technology. Object serialization can be used in many different ways from simple persistence, writing and read to/from files, or for RMI to communicate across hosts.

Q             Why is OutOfMemoryError thrown after writing a large number of objects into an ObjectOutputStream?  
A             The ObjectOutputStream maintains a table mapping objects written into the stream to a handle. The first time an object is written to a stream, its contents are written into the stream; subsequent writes of the object result in a handle to the object being written into the stream. This table maintains references to objects that might otherwise be unreachable by an application, thus, resulting in an unexpected situation of running out of memory. A call to the ObjectOutputStream.reset() method resets the object/handle table to its initial state, allowing all previously written objects to be eligible for garbage collection.

Q             Why is UTFDataFormatException thrown by DataOutputStream.writeUTF() when serializing a String?  
A             DataOutputStream.writeUTF() does not support writing out strings larger than 64K. The first two bytes of a UTF string in the stream are the length of the string. If a java.lang.String can be larger than 64K, it needs to be stored in the stream by an alternative method rather than depending on the default method of storing a String in the stream, writeUTF.

Q             How can I create an ObjectInputStream from an ObjectOutputStream without a file in between?  
A             ObjectOutputStream and ObjectInputStream work to/from any stream object. You could use a ByteArrayOutputStream and then get the array and insert it into a ByteArrayInputStream. You could also use the piped stream classes as well. Any class that extends the OutputStream and InputStream classes can be used.
Alternatively, the ObjectOutputStream> class implements a reset method that discards the memory of having sent an object, so sending an object again will make a copy.

Q             Why a file that contains multiple appended ObjectOutputStreams can’t be deserialized by one ObjectInputStream?  
A             Using the default implementation of serialization, there must be a one-to-one mapping between ObjectOutputStream construction and ObjectInputStream construction. ObjectOutputStream constructor writes a stream header andObjectInputStream reads this stream header. A workaround is to subclass ObjectOutputStream and override writeStreamHeader(). The overriding writeStreamHeader() should call the super writeStreamHeader method if it is the first write to the file and it should call ObjectOutputStream.reset() if it is appending to a pre-existing ObjectOutputStream within the file.

Q             What is a platform?
A             A platform is the hardware or software environment in which a program runs. Most platforms can be described as a combination of the operating system and hardware, like Windows 2000/XP, Linux, Solaris, and MacOS.

Q             What is the main difference between Java platform and other platforms?
A             The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms.
The Java platform has two components:
The Java Virtual Machine (Java VM)
The Java Application Programming Interface (Java API)

Q             What is the Java Virtual Machine?
A             The Java Virtual Machine is a software that can be ported onto various hardware-based platforms.

Q             What is the Java API?
A             The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.

Q             What is the package?
A             The package is a Java namespace or part of Java libraries. The Java API is grouped into libraries of related classes and interfaces; these libraries are known as packages.

Q             What is native code?
A             The native code is code that after you compile it, the compiled code runs on a specific hardware platform.

Q             Is Java code slower than native code?
A             Not really. As a platform-independent environment, the Java platform can be a bit slower than native code. However, smart compilers, well-tuned interpreters, and just-in-time bytecode compilers can bring performance close to that of native code without threatening portability.

Q             What is the serialization?
A             The serialization is a kind of mechanism that makes a class or a bean persistence by having its properties or fields and state information saved and restored to and from storage.

Q             How to make a class or a bean serializable?
A             By implementing the interface

Q             How many methods in the Serializable interface?
A             There is no method in the Serializable interface. The Serializable interface acts as a marker, telling the object serialization tools that your class is serializable.

Q             What is a transient variable?
A             A transient variable is a variable that may not be serialized. If you don't want some field to be serialized, you can mark that field transient or static.

Q             Which containers use a border layout as their default layout?
A             The Window, Frame and Dialog classes use a border layout as their default layout.

Q             What is synchronization and why is it important?
A             With respect to multithreading, synchronization is the capability to control the access of multiple threads to shared resources. Without synchronization, it is possible for one thread to modify a shared object while another thread is in the process of using or updating that object's value. This often causes dirty data and leads to significant errors.

Q             What are synchronized methods and synchronized statements?
A             Synchronized methods are methods that are used to control access to an object. A thread only executes a synchronized method after it has acquired the lock for the method's object or class. Synchronized statements are similar to synchronized methods. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

Q             What are three ways in which a thread can enter the waiting state?
A             A thread can enter the waiting state by invoking its sleep() method, by blocking on I/O, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

Q             Can a lock be acquired on a class?
A             Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object.

Q             What's new with the stop(), suspend() and resume() methods in JDK 1.2?
A             The stop(), suspend() and resume() methods have been deprecated in JDK 1.2.

Q             What is the preferred size of a component?
A             The preferred size of a component is the minimum component size that will allow the component to display normally.

Q             What method is used to specify a container's layout?
A             The setLayout() method is used to specify a container's layout.

Q             Which containers use a FlowLayout as their default layout?
A             The Panel and Applet classes use the FlowLayout as their default layout.

Q             What is thread?
A             A thread is an independent path of execution in a system.

Q             What is multithreading?
A             Multithreading means various threads that run in a system.

Q             How does multithreading take place on a computer with a single CPU?
A             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.

Q             How to create multithread in a program?
A             You have two ways to do so. First, making your class "extends" Thread class. Second, making your class "implements" Runnable interface. Put jobs in a run() method and call start() method to start the thread.

Q             Can Java object be locked down for exclusive use by a given thread?
A             Yes. You can lock an object by putting it in a "synchronized" block. The locked object is inaccessible to any thread other than the one that explicitly claimed it.

Q             Can each Java object keep track of all the threads that want to exclusively access to it?
A             Yes.

Q             What state does a thread enter when it terminates its processing?
A             When a thread terminates its processing, it enters the dead state.

Q             What invokes a thread's run() method?
A             After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

Q             What is the purpose of the wait(), notify(), and notifyAll() methods?
A             The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to communicate each other.

Q             What are the high-level thread states?
A             The high-level thread states are ready, running, waiting, and dead.

Q             What is the Collections API?
A             The Collections API is a set of classes and interfaces that support operations on collections of objects.

Q             What is the List interface?
A             The List interface provides support for ordered collections of objects.

Q             How does Java handle integer overflows and underflows?
A             It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

Q             What is the Vector class?
A             The Vector class provides the capability to implement a growable array of objects

Q             What modifiers may be used with an inner class that is a member of an outer class?
A             A (non-local) inner class may be declared as public, protected, private, static, final, or abstract.

Q             If a method is declared as protected, where may the method be accessed?
A             A 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.

Q             What is an Iterator interface?
A             The Iterator interface is used to step through the elements of a Collection.

Q             How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
A             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.

Q             What is the difference between yielding and sleeping?
A             When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

Q             Is sizeof a keyword?
A             The sizeof operator is not a keyword.

Q             What are wrapped classes?
A             Wrapped classes are classes that allow primitive types to be accessed as objects.

Q             Does garbage collection guarantee that a program will not run out of memory?
A             No, it doesn't. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection

Q             What is the difference between preemptive scheduling and time slicing?

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

All The Best ....!



addressing modes types,1,advance-java,2,advancejava,1,aktu entrance exam,1,aktu exam schedule,1,ASP,1,bare machine,1,base register and limit register,1,C Programming,13,C Plus Plus,1,C Programming,6,C Programming MCQ,2,C Programming Questions,2,C programming study material for gate exam,10,Cache Memory,1,CBNST Program,1,Childcare,1,CJ,2,Cloud Computing,1,COA GATE Questions,1,components of use case diagram,1,Computer Architecture,2,Computer architecture based questions for gate exam,11,Computer Network,4,Computer Network Study Material,2,Computer network study material for gate,2,Computer Networks,6,Computer networks GATE Questions,1,Computer Science Study Material for Gate,19,computer science study material for gate exam,32,content based image retrieval content based image retrieval system,1,contiguous memory allocation,2,Core Java,8,COre Java Interview Questions,1,core java interviews questions,1,cyber crime report,1,Cyber crime status,1,cybercrime and security,1,cybercrime examples,1,Data Mining,1,Data Structure,2,Data Structure Questions,1,Data Transmission Architecture,1,Data Transmission in wsn,1,DBMS,5,dbms question paper,1,DE,1,Digital Electronics,1,DS,4,dynamic linking,1,dynamic linking in memory management,1,Dynamic memory allocation in c,1,Electroencephalogram,1,file management in operating system notes,1,FOC,1,Fundamenatl of Computer,1,Gate 2017,5,Gate 2017 Admit card,1,Gate 2017 Exam Schedule,1,Gate 2017 Syllabus,1,gate 2018,1,gate cse study material,1,gate practice set,10,gate study material for computer science,16,Gate study material for computer science 2017,1,GatePreviousYear,1,General,3,HCL Aptitude Test,1,HR Interview Questions,1,HTML,4,Image Processing,1,Important Date of Gate 2017 Exam,1,Information Security Policy,1,internal and external fragmentation,1,JS,1,lagrange's interpolation formula,1,lagrange's interpolation formula examples,1,MComputing,1,memory fragmentation,1,memory management,1,memory management questions and answer in os,1,Motivational,4,NCER,2,Numerical Techniques Lab,1,OOT,1,Operating System,12,Operating System Gate Questions,1,Operating System Objective Questions,4,Operating System Questions Bank,1,Operating system questions for gate,1,Operating System Study material,2,operating system study material for gate exam,16,Operating system tutorial,2,page swapping,1,paged memory allocation,1,paged memory allocation in operating system,1,paging technique of memory management .paging technique,1,paging technique of memory management program in c,1,Pointer in C,4,Process based question for gate,1,Quiz on non conventional energy resources,1,Regression testing,1,relocation in memory management,1,relocation registe,1,relocation register,1,resident monitor,1,resident monitor in operating system,1,routing table,1,segmentation in memory management,1,segmentation in memory management in operating system,1,Servlet,1,session tracking,1,session tracking in java,1,session tracking in servlet,1,Software Engineering,10,Software Engineering baes study material for gate,1,software engineering interview questions,1,Software Quality Assurance,3,software verification methods,1,SPM,1,Stack,1,Structure in C,1,Study Material for gate Computer Science,9,swapping in memory management,1,swapping in operating system,1,TCS Code Vita,1,TCS Interview Questions,1,Technical Interview,1,Technical Questions from DBMS,1,Thrashing in Operating System,1,Threads concept in operating system,1,Tips to Learn Coding,1,Top 30 Core Java Interview Questions with Answer,2,top down approach,1,top down approach in programming,1,Types of operating system,1,UML,1,use case diagram explanation,1,website uses cookies,1,what is cookies website,1,What is process control block ?,1,what is software testing?,1,Wireless Sensor Network,3,worst fit algorithm for memory allocation,1,XML,2,
Computer Science Junction: Interview Questions from Core Java
Interview Questions from Core Java
Technical Questions from Core Java , Collections , Interview questions are related to use of this and super Keyword operators, JVM and Jdk, thread, Interface and access specifier, methods , class, java collections, seriazable in java , hastable , jsp servlet etc.
Computer Science Junction
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share. STEP 2: Click the link you shared to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy