Home » Java programming language

Java Programming Language – Interview Questions & Answers (Page -3)

Differentiate the #include and import statement?

In C/C++ we use #include directive, it is used to make the compiler go to the standard library and copy the code from header files to our program. So that code size is increases, thus wasting memory and processor’s time.

In JAVA we use import statement, it is used to make the Java Virtual Machine go to the standard library, and execute the code there, and substitute the output into our program. So that there is no need to copy the code. Hence no wastes of memory, so we can say import is an efficient than #include.

What is the main difference between float and double?

We can represent float variable value up to 7 digits after decimal point, whereas double value can be represent up to 15 digits after decimal point.

Define Unicode?

Unicode stands for Universal code. It provides a unique number for every character; it is platform and language independent. It uses 2 bytes to represent a single character.

Define the internal representation of positive and negative number.

Positive numbers are represented in binary language with the help of 1’s complement and negative numbers are represented with the help of 2’s complement.

Define collection?

A collection is a group of elements like integer values or objects like arrays and java.util classes (Stack, Queue, and Linked List).

Is goto statement available in java?

It is not available in java but keyword is revered for it in java. As we know that it creates confusion in large program.

Differentiate return and system.exit(0)?

As we know that return is a jumping statement which is used to transfer control from called method to calling method, whereas System.exit(0) is a method, which is used to come out of the program.

Differentiate System.out and System.err?

In java both objects are represents monitor by default. They are used to send data to the monitor. But System.out is used to print normal messages whereas System.err is used to print error messages.

What happens when String args[] is not used in main() method?

String args[] used for command line argument in java. If we will not use String args[] then it will be an compiler error. Because JVM always looks for main() method with string type array as argument.

Can a Java program have multiple classes?

Yes, A Java program can have multiple classes. But there is only single public class in a Java program.

What is a public class in Java?

A class which can be accessed anywhere outside of the package. You can also access the public class in another package.

What is a package in Java?

A package is a namespace/ folder, which contains set of related classes, interfaces and resources.

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.