Java Interview Questions Set 4
Categories: Java 8(JDK1.8)
What is the output of the following Java program?
class Test
{
public static void main (String args[])
{
System.out.println(10 * 20 + "Javatpoint");
System.out.println("Javatpoint" + 10 * 20);
}
}
The output of the above code will be
200Javatpoint
Javatpoint200
What is the output of the following Java program?
class Test
{
public static void main (String args[])
{
for(int i=0; 0; i++)
{
System.out.println("Hello Javatpoint");
}
}
}
The above code will give the compile-time error because the for loop demands a boolean value in the second part and we are providing an integer value, i.e., 0.
What do you mean by object-oriented paradigm?
It is a programming paradigm based on objects having data and methods defined in the class to which it belongs. Object-oriented paradigm aims to incorporate the advantages of modularity and reusability. Objects are the instances of classes which interacts with one another to design applications and programs. There are the following features of the object-oriented paradigm.
a) Follows the bottom-up approach in program design.
b) Focus on data with methods to operate upon the object's data
c) Includes the concept like Encapsulation and abstraction which hides the complexities from the user and show only functionality.
d) Implements the real-time approach like inheritance, abstraction, etc.
e) The examples of the object-oriented paradigm are C++, Simula, Smalltalk, Python, C#, etc.
What is an object?
The Object is the real-time entity having some state and behavior. In Java, Object is an instance of the class having the instance variables as the state of the object and the methods as the behavior of the object. The object of a class can be created by using the new keyword.
What is the difference between an object-oriented programming language and object-based programming language?
There are the following basic differences between the object-oriented language and object-based language.
a) Object-oriented languages follow all the concepts of OOPs whereas, the object-based language doesn't follow all the concepts of OOPs like inheritance and polymorphism.
b) Object-oriented languages do not have the inbuilt objects whereas Object-based languages have the inbuilt objects, for example, JavaScript has window object.
c) Examples of object-oriented programming are Java, C#, Smalltalk, etc. whereas the examples of object-based languages are JavaScript, VBScript, etc.