Tech Msd
Advertisement
  • Home
  • Technology
    • Windows
    • Software
    • Android
      • Apps
      • Mobiles
      • Social Media
  • Business
    • Digital Marketing
    • Web Design
  • News
  • Finance
    • Cryptocurrency
  • How to
  • Lifestyle
    • Home & Garden
    • Health
  • Entertainment
    • Movies
No Result
View All Result
  • Home
  • Technology
    • Windows
    • Software
    • Android
      • Apps
      • Mobiles
      • Social Media
  • Business
    • Digital Marketing
    • Web Design
  • News
  • Finance
    • Cryptocurrency
  • How to
  • Lifestyle
    • Home & Garden
    • Health
  • Entertainment
    • Movies
No Result
View All Result
Tech Msd
No Result
View All Result
Home Interview Questions

Most Frequently Asked Questions on JAVA Interview

by Mahesh
May 11, 2018
in Interview Questions

Most Frequently Asked Questions on JAVA Interview

At the heart of Java technology lies the JVM ( Java Virtual Machine)… the abstract computer on which all Java program run. JVM is the primary component of the Java system responsible for portability. Java Programs execute whitin the VM itself. The purpose of VM is to allow Java programs to compile to uniform executable format, as defined by the VM, that can run on any platform. Generally, Java is used to refer to the Java programming language, but Java also includes JVM, Java API, and Java class me. It’s very important to learn before we go indepth of Java interview questions.

Java Programs go through five phases:

1)      Edit

2)      Compile

3)      Load

4)      Verify

5)      Execute

In next Section we will discuss important Java interview questions in list format:

Question 1) Why the execution of a Java program is slow?

Answer) Java is slow because of extra load it takes in housekepping.

Question 2) What is Method Overlaoding and where is it useful give with example?

Answer) Reusing the same method name, with different arguments and with the same or different return type is called Method overloading. The OOP concept, method overloading avoids the usage of several method names that perform closely related jobs( functionality). That’s is to say method overloading eliminates the need for entirely different methods that do essentially the same thing.

Example Program:

Public class OverloadDemo {

Public void area(int x) {

System.out.println(“The area of the circle is “+Math.Pi*x*x”); // first method

}

Public void area( String figure,int x) {                                                    // Second Method

If(figure.equals(“circle”))

System.out.println(“The area of the circle is “+Math.Pi*x*x”);

elseif(figure.equals(“square”))

System.out.println(“The area of the circle is “+ x*x);

else

System.out.println(“Please Pass either circle or square only as argument”);

}

Public int area( int l, int b) {

return l*b;

}

Public float area(int a, int b, int c) {

double s= (a+b+c/2;

return s*Math.sqrt((s-a)* (s-b)+ (s-c) ) );

}

Public double area(int a, int b, int c) {

double s= (a+b+c/2;

return s*Math.sqrt((s-a)* (s-b)+ (s-c) ) );

}

Publics static void main(String ars[]) {

OveloadDemo od=new OveloadDemo();

od.area(5);

od.area (“circle”,7);

od.area(“square”, 4);

od.area(“traiangle”, 10);

System.out.println(“The area of rectangle is “ +od.area(20,10)); // 3rd method

System.out.println(“The area of the triangle is “ + Math.ceil(od.area(3,4,5))); // 4th method System.out.println(“The area of the triangle is “ + Math.round(od.area(3,4,5,6,7)));// 5th method

}

}

Out Put of the Java interview questions program

The area of the circle is 78.53981633974483

The area of the circle is 153.9380400258995

The area of the circle is 16

Please Pass either circle or square only as argument

The area of the rectangle is 200

The area of the triangle is 16.0

The area of the triangle is 14

In the above Java interview questions program area() method is overloaded. Math us a class defined in the package java,lang which is imported by default by the JVM. Math class includes many static methods like round(), floor() etc. Student is advised to refer to Java documentation for more methods and for in depth knowledge of Math class.

Question 3) What is inheritance?

Answer) Inheritance is a mechanism that enables one class to inherit all of the behavior (methods) and attributes ( instance variables) of another class. A class that inherits from another class is defines a subclass and the class that gives the inheritance is called supercalss.

The above Java interview questions is frequently asked by the Java interviewer. So friends be well prepared for the interview. This is pure Java next step is to prepare for J2ee interview questions.

ShareTweetSharePin
Previous Post

Frequently Asked Questions on J2EE Interview Questions

Next Post

Amazing Girl Playing with the Ball: You wont be believe until you see this

Mahesh

Mahesh

I'm an Engineer by profession and Writer by passion. I am working as a Content Marketer at TechMsd.com. I have been writing for more than 5 years, mostly on technology. I have experience includes writing, public speaking, and ghostwriting articles, blogs, and business communications across several industries. I like to watch foreign-language movies and public speaking.

Related Posts

Manual testing interview questions
Interview Questions

Top 10 Frequently Asked Questions on Manual Testing Interview

May 11, 2018
Interview Questions

Frequently Asked Questions on J2EE Interview Questions

May 11, 2018
Next Post
Amazing Girl Playing with the Ball: You wont be believe until you see this

Amazing Girl Playing with the Ball: You wont be believe until you see this

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

5 Hot Web Development Trends for 2023

5 Hot Web Development Trends for 2023

November 24, 2022
10 Tips to Better Improve Your Flyer Designs

10 Tips to Better Improve Your Flyer Designs

October 4, 2022

How to Create a More Flexible Working Environment

July 29, 2022
What is the Purpose of Decommissioning?

What is the Purpose of Decommissioning?

May 30, 2022
Critical factors to know for succeeding at trading

Why is using a good broker in Dubai essential for trading?

May 30, 2022
What Is a Credit Score and How Can it Save You Money on Your Mortgage?

What Is a Credit Score and How Can it Save You Money on Your Mortgage?

May 30, 2022
Discover the Benefits of Block Games to All Gamers

Discover the Benefits of Block Games to All Gamers

May 30, 2022
The Need For Zero Trust Model to Protect Sensitive Data

The Need For Zero Trust Model to Protect Sensitive Data

May 30, 2022
Factors to Consider When Hiring a Motorcycle Accident Attorney

Factors to Consider When Hiring a Motorcycle Accident Attorney

December 13, 2021
Photo Ideas For Your Next Selfie

5 Photo Ideas For Your Next Selfie: Add Creativity To Your Selfies

November 26, 2021
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Submit Guest Post

ABOUT
Tech Msd is one of the top and most famous technology blog on the internet which covers latest technology news, gadgets, science and interesting stuff and provides helpful guides to the internet users.
© 2020 Tech Msd. All Rights Reserved.

No Result
View All Result
  • Home
  • Technology
    • Windows
    • Software
    • Android
      • Apps
      • Mobiles
      • Social Media
  • Business
    • Digital Marketing
    • Web Design
  • News
  • Finance
    • Cryptocurrency
  • How to
  • Lifestyle
    • Home & Garden
    • Health
  • Entertainment
    • Movies

© 2021 TechMSD