Fundamentals Level 1

Q. What are the buzz words of java?

Ans: simple, object-oriented, network-savvy, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, dynamic.



Q. What are the reasons for using java?

Ans:

1. Object Oriented

2. Built in support for

  • Multi-threading
  • Memory Management (Garbage collection)

3. Platform Independent

4. Supports

  • Distributed applications (RMI, Sockets, etc)
  • Web applications (Applet, Servlet, JSP)
  • Network protocols (HTTP, JRMP, etc)

5. Availability of extensive standardised APIs


Q. What is the difference between a constructor and a method?

Ans:

A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.

A method is an ordinary member function of a class. It has its own name, a return type (which may be void if nothing to return), and is invoked using the dot operator.



Q. Is Empty .java file a valid java source file?
Ans: Yes, an empty .java file is a perfectly valid java source file.



Q. Is it necessary to import java.lang package? Why ?

Ans: No. It is loaded internally by the JVM by default.



Q. Can one .java file can contain more than one class?

Ans: Yes, one .java file can contain more than one java classes, provided only one of them is a public class.



Q. Is there any difference between declaring and defining a variable?
Ans: Yes,

In declaration we mention only the type of the variable and it's name, we do not initialize it. But defining means declaration + initialization.



Q. What type of parameter passing is supported by java?
Ans: The arguents are always passed by value.



Q. What if a method or a field is static?
Ans:

Static variables and methods are instantiated only once per class. In other words they are the class variables, not instance variables. If you change the value of a static variable in using a particular object, the value of that variable reflects for all the other 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 , that works too.

Eg: System.out.println(), out is a static field in the java.lang.System class.



Q. What is java API?
Ans: Java Application Programming Interface (Java API) is a set of classes written using the Java language and run on the JVM.


AddThis Feed Button
Please provide your feedback by sending an email to 1234java.blogspot@gmail.com. This would help me making the site more helpful. Thanks in advance.

DISCLAIMER:

The content provided in this article/site is not warranted or guaranteed by 1234java.blogspot.com. The content provided is intended for educational purposes in order to introduce to the reader key ideas, concepts. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials.