1. What do you mean by object oriented programming.
Ans. Object -oriented programming is a programming concept where we first create an object then we define the characteristics or functions of an object in the form of data known as fields and methods.
examples of OOP programming are java,c++,python,VB.net and ruby.
simula was the first oop language.2.Difference between Abstraction and Encapsulation :-
Four important concepts or principles in Java areData encapsulationData abstractionInheritancePolymorphism
1. Abstraction solves the problem in the design level.
1. Encapsulation solves the problem in the implementation level.
2. Abstraction is used for hiding the unwanted data and giving relevant data.
2. Encapsulation means hiding the code and data into a single unit to protect the data from outside world.
3. Abstraction lets you focus on what the object does instead of how it does it
3. Encapsulation means hiding the internal details or mechanics of how an object does something.
4. Abstraction– Outer layout, used in terms of design.
Outer Look of a Mobile Phone, like it has a display screen and keypad buttons to dial a number.
4. Encapsulation– Inner layout, used in terms of implementation.
For Example:- Inner Implementation detail of a Mobile Phone, how keypad button and Display Screen are connect with each other using circuits.
The easier way to understand Abstraction and encapsulation is as follows:-
Real World Example:-
Take an example of Mobile Phone:-
You have a Mobile Phone, you can dial a number using keypad buttons. Even you don’t know how these are working internally. This is called Abstraction. You have the only information that is needed to dial a number. But not its internal working of mobile.
But how the Mobile Phone internally working?, how keypad buttons are connected with internal circuit? is called Encapsulation.
“Encapsulation is accomplished by using Class. – Keeping data and methods that accesses that data into a single unit”
“Abstraction is accomplished by using Interface. – Just giving the abstract information about what it can do without specifying the back ground details”
“Information/Data hiding is accomplished by using Modifiers – By keeping the instance variables private or protected.”
The Java Virtual machine (JVM) is the virtual machine that run the Java bytecodes. The JVM doesn’t understand Java source code, that’s why you compile your
*.java files to obtain
*.class files that contain the bytecodes understandable by the JVM. It’s also the entity that allows Java to be a “portable language” (write once, run anywhere). Indeed there are specific implementations of the JVM for different systems (Windows, Linux, MacOS, see the wikipedia list..), the aim is that with the same bytecodes they all give the same results.
4.what is byte code?
Ans. A byte code is an encrypted binary representation of java program when it is compiled.
5.Why java is called compiler -interprter language?
Ans.Java is both Compiled and interpreted Language. Therefore Executing a java program is two stage process:
1) Compiling a source file(.java) and create byte code file(.class)
2) Interpreting byte code(.class) file and create binary code(.exe)file
See the diagram:
i) Java program is converted into byte code file by java compiler(javac)
ii) JVM converts byte code file into binary code (.exe) file i.e. instructions which can be understood by operating system and hardware directly.
This two stage process makes java platform independent as java files are not directly converted to executable files instead they are converted to byte code file which can be used on any platform.
For more features refer following link:
6.Java Command Line Arguments
The java command-line argument is an argument i.e. passed at the time of running the java program.
The arguments passed from the console can be received in the java program and it can be used as an input.
So, it provides a convenient way to check the behavior of the program for the different values. You can pass N (1,2,3 and so on) numbers of arguments from the command prompt.
Simple example of command-line argument in java
|In this example, we are receiving only one argument and printing it. To run this java program, you must pass at least one argument from the command prompt.
Output: Your first argument is: sonoo
Example of command-line argument that prints all the values
|In this example, we are printing all the arguments passed from the command-line. For this purpose, we have traversed the array using for loop.