Top 30 Core Java Interview Questions with Answer for Freshers

Most Frequently Asked Interview Question in Java,Top 50 Core Java Interview Questions with Answer for freshers,

Most Frequently Asked Interview Question in Java

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 Variable, operators, JVM and Jdk, Interface and access specifier. 

top 50 java interview questions with answer for freshers

Basics Important Questions  for freshers from Core Java

Q             Can there be an abstract class with no abstract methods in it?  

A             Yes.

Q             Can an Interface be final?

A             No.

Q             Can an Interface have an inner class?  

A             Yes
public interface abc {
            static int i=0;
            void dd();
            class a1 {
                        a1() {
                                    int j;
                                    System.out.println("in interfia");
                        public static void main(String a1[]) {
                                    System.out.println("in interfia");

Q             Can we define private and protected modifiers for variables in interfaces?  

A             No

Q             What is Externalizable?  

A             Externalizable is an Interface that extends Serializable Interface and sends data into Streams in Compressed Format. It has two methods, writeExternal(ObjectOuput out) and readExternal (ObjectInput in)

Q             What modifiers are allowed for methods in an Interface?  

A             Only public and abstract modifiers are allowed for methods in interfaces.

Q             What is a local, member and a class variable?  

A             Variables declared within a method are "local" variables. Variables declared within the class i.e. not within any methods are "member" variables (global variables).Variables declared within the class i.e. not within any methods and are defined as "static" are class variables

Q             I made my class Cloneable but I still get 'Can't access protected method clone. Why?  

A             you have to implement your own public clone() method, even if it doesn't do anything special and just calls super.clone().

Q             Can we overload main method in java?  

A             Yes. But the main method with String args[] is called when you call the program (java Test1) Have a look at this demo.
 public class Test1{
            public static void main(String[] args){
                        System.out.println("in main method");
            public static void main(String args[],String arg){
                        System.out.println("in overload method");

Q             What are some alternatives to inheritance?  

A             Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the instance. It is often safer than inheritance because it forces you to think about each message you forward, because the instance is of a known class, rather than a new class, and because it doesn't force you to accept all the methods of the super class: you can provide only the methods that really make sense. On the other hand, it makes you write more code, and it is harder to re-use (because it is not a subclass).

Q             Why isn't there operator overloading?  

A             Because C++ has proven by example that operator overloading makes code almost impossible to maintain. In fact there very nearly wasn't even method overloading in Java, but it was thought that this was too useful for some very basic methods like print(). Note that some of the classes like DataOutputStream have unoverloaded methods like writeInt() and writeByte().

Q             What does it mean that a method or field is "static"?  

A             Static variables and methods are instantiated only once per class. In other words they are class variables, not instance variables. If you change the value of a static variable in a particular object, the value of that variable changes for all instances of that class.

Static methods can be referenced with the name of the class rather than the name of a particular object of the class (though that works too). That's how library methods like System.out.println() work. out is a static field in the java.lang.System class.

Q             Difference between JRE And JVM AND JDK  

Java Development Kit (JDK)

A software development environment for writing applets and applications in the Java programming language. Technically, the JDK is the correct name for all versions of the Java platform.

Java virtual machine

A software "execution engine" that safely and compatibly executes the byte codes in Java class files on a microprocessor (whether in a computer or in another electronic device

Java Runtime Environment (JRE)

A subset of the Java Development Kit (JDK) for end-users and developers who want to redistribute the runtime environment alone. The Java runtime environment consists of the Java virtual machine1, the Java core classes, and supporting files.

Q             Why do threads block on I/O?  

A             Threads block on i/o (that is enters the waiting state) so that other threads may execute while the i/o Operation is performed

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 leads to significant errors.

Q             Is null a keyword?  

A             The null value is not a keyword.

Q             Which characters may be used as the second character of an identifier, but not as the first character of an identifier?  

A             The digits 0 through 9 may not be used as the first character of an identifier but they may be used after the first character of an identifier.

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             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 are wrapped classes?  

A             Wrapped classes are classes that allow primitive types to be accessed as objects.

Q             What restrictions are placed on the location of a package statement within a source code file?  

A             A package statement must appear as the first line in a source code file (excluding blank lines and comments).

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.

Q             What is a native method?  

A             A native method is a method that is implemented in a language other than Java.

Q             What is order of precedence and Associativity, and how are they used?  

A             Order of precedence determines the order in which operators are evaluated in expressions. Associativity determines whether an expression is evaluated left-to-right or right-to-left

Q             What is the catch or declare rule for method declarations?  

A             If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

Q             Can an anonymous class be declared as implementing an interface and extending a class?  

A             An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

Q             What is the range of the char type?  

A             The range of the char type is 0 to 2^16 - 1.

Q             What is the purpose of finalization?  

A             The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

Q             What is the difference between the Boolean & operator and the && operator?  

A             If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.

Q             How many times may an object's finalize() method be invoked by the garbage collector?  

A             An object's finalize() method may only be invoked once by the garbage collector.

Q             What is the purpose of the finally clause of a try-catch-finally statement?  

A             The finally clause is used to provide the capability to execute code no matter whether or not an exception is thrown or caught.

Q             What is the argument type of a program's main() method?  

A             A program's main() method takes an argument of the String[] type.

Q             Which Java operator is right associative?  

A             The = operator is right associative.

Q             Can a double value be cast to a byte?  

A             Yes, a double value can be cast to a byte.

Q             What is the difference between a break statement and a continue statement?  

A             A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.

Q             What must a class do to implement an interface?  
A             It must provide all of the methods in the interface and identify the interface in its implements clause.

Q             What is the advantage of the event-delegation model over the earlier event-inheritance model?  

A             The event-delegation model has two advantages over the event-inheritance model. First, it enables event handling to be handled by objects other than the ones that generate the events (or their containers). This allows a clean separation between a component's design and its use. The other advantage of the event-delegation model is that it performs much better in applications where many events are generated. This performance improvement is due to the fact that the event-delegation model does not have to repeatedly process unhandled events, as is the case of the event-inheritance model.

Q             How are commas used in the intialization and iteration parts of a for statement?  

A             Commas are used to separate multiple statements within the initialization and iteration parts of a for statement.

Q             What is an abstract method?  

A             An abstract method is a method whose implementation is deferred to a subclass.

Q             What value does read() return when it has reached the end of a file?  

A             The read() method returns -1 when it has reached the end of a file.

Q             Can a Byte object be cast to a double value?  

A             No, an object cannot be cast to a primitive value.

Q             What is the difference between a static and a non-static inner class?  

A             A non-static inner class may have object instances that are associated with instances of the class's outer class. A static inner class does not have any object instances.

Q             If a variable is declared as private, where may the variable be accessed?  

A             A private variable may only be accessed within the class in which it is declared.

Q             What is an object's lock and which object's have locks?  

A             An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock. All objects and classes have locks. A class's lock is acquired on the class's Class object.

Q             What is the % operator?  
A             It is referred to as the “modulo” or “remainder” operator. It returns the remainder of dividing the first operand by the second operand.

To read more on core java questions and answer click here -

Short Questions Answer from Core Java

Keywords: Java Technical Questions, Java Interview Questions,Most Frequently Asked Interview Question in Java



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: Top 30 Core Java Interview Questions with Answer for Freshers
Top 30 Core Java Interview Questions with Answer for Freshers
Most Frequently Asked Interview Question in Java,Top 50 Core Java Interview Questions with Answer for freshers,
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