Sunday, March 23, 2014

Java Programming Questions & Answers

My teacher gave me an assignment. It was about Java Programming. I completed it and now uploading it in my blog. It maybe helpful for the new Java programmers like me. It was given by Shah  Mostafa Khaled (MTD) Sir as an assignment of CSE 135 (now known as CSE 215) course of North South University.



  • Why is Java a static language?



There are two forms of typed programming languages. One is statically typed language and another is dynamically typed language. Statically typed language requires you to declare what ‘type’ a variable is when you are writing code. On the other hand, dynamically typed languages do not need to be declared the type of the variable in the code.


Java is a statically typed language. Because all the type of variables inside the code must be declared. Moreover, Java is a well-established and old language. It is going through development. But the basic structures of the language and codes are the same for many years. They will remain almost same fort the next years. So, Java programmes written in twenty first century can be easily edited and supported in the future decades.



  •  What is the benefit of it?



There are many benefits of static language. Suppose, someone wrote a code in dynamic language many years ago. A software is running with those codes. If the language is dynamic then the structure and rules of that language will change day by day. In the end, the coder will end up facing that his software is of no use for the current time. Upgrading the software may cause excessive costs. That’s why static language is better to use. It will remain almost same time to time.
Moreover, in statically typed language you have to declare the type of an variable. This clears the confusion pretty early. Static languages are fast and more reliable.



  •  What is Java Spec?


Java Spec is a complete reference to rules and conditions of Java Language. Java Specifications Requests (JSRs) is formal documents that describe proposed specifications and technologies for adding to the Java platform. Formal public reviews of JSRs take place before a JSR becomes final and the JCP Executive Committee votes on it. A final JSR provides a reference implementation that is a free implementation of the technology in source code form and a Technology Compatibility Kit to verify the API specification.



  •  How do changes come to Java Language?


Java is a community-based language. It is developed by not only by a organization but also a bunch of users. These java users contribute to the community and help tyo develop the language day by day. The changes in the language occurs by the decision of the community members. If the members agree to change something in the language then it is only considered to be changed and developed.



  •  Is Java a compiled language or interpereted language?


Java is both a compiled language and interpreted language. Java uses a two –step compilation process. First, Java source code is compiled into ‘’bytecode’’ by the Java compiler. The bytecode can be executed by Java Virtual Machine (JVM). The current version of JVM is called Just In Time (JIT) Compilation. Then the JIT compiler interpret the bytecode into native instructions understood by the CPU to run the program.



  •  What is the difference between Compiled Language and Interpreted Language?


A compiled language is a programming language whose implementations are generally compilers. It generates machine code from source code. A compiler can translate the source code into some intermediate form often called bytecode, which is then passed to an interpreter which executes it. Compiled programs generally run faster than interpreted ones because interpreted programs must be reduced to machine instructions at runtime.

An interpreted language is a programming language that executes instructions directly, without previously compiling a program into machine-language instructions. The interpreter executes the program directly, translating each statement into a sequence of one or more subroutines already compiled into machine code. An interpreted program runs slower than compiled program because it translates every sequence of the code simultaneously.



  • What is JIT Compiler?

JIT Compiler is the short form for Just-In-Time Compiler. It is a code generator that converts Java bytecode into machine language instructions. Some Java Virtual Machine (JVM) have JIT Compiler included. Java programs compiled by JIT runs much faster.



  • How many commenting styles are there in Java? Give example.


There are three types of commenting styles in Java programming.
1.       1. Single Line Comment: The simplest comment in Java is the single line comment. It starts with two forward slashes and continues to the end of the line.




Example: // This is a single line comment.

2. Multi Line Comment: This type of comment starts with a forward slash followed by an asterisk, and end it with an asterisk followed by a forward slash.



Example: /* This is a
              Multi line
              Commenting style */
3.      
3    3. Documentation Comment: This type of comments begin with a forward slash followed by two asterisks, and end with an asterisk followed by a forward slash.
 
Example: /** This is a documentation comment */
 


  • Why main method is static in Java?





Main methos is static in Java Programming language. Java virtual machine can call it 
without creating any instance of class which contains main methos. If main method 
were not declared static then JVM has to create instance of main class and since 
constructor can be overloaded and can have argumants there would not be any certain 
and easy way for JVM to find main method in Java.
 


  •  What is package in Java? Give example.


 
A Java package is a set of classes which are grouped together. Every class is part 
of some package. All classes in a file are part of the same package.
 
Multiple files can specify the same package name. If no package is specified, the 
classes in the files are stored into an unnamed package. If package name is specified,the 
file must be in a subdirectory called the name which must match the package name. 
 
Examples of Java Packages:

java.applet 

java.awt 

java.awt.color 

java.awt.datatransfer 

java.awt.dnd 

java.awt.event 

java.awt.font 

java.awt.geom 

java.awt.im 

java.awt.im.spi 

java.awt.image 

java.awt.image.renderable 

java.awt.print 

java.beans 

java.beans.beancontext 

java.io 

java.lang 

java.lang.ref 

java.lang.reflect 

java.math 

java.net 

java.nio 

java.nio.channels 

java.nio.channels.spi 

java.nio.charset 

java.nio.charset.spi
 
 



10 comments:

  1. Thankyou brother.
    I'm also MTD sir's student. This helped me a lot with the Assignment.

    ReplyDelete
  2. thans bro,,, really liked your artical,,,,very helpful and thanks a lot for your artical again.

    ReplyDelete
  3. thans bro,,, really liked your article,,,,very helpful and thanks a lot for your article again.

    ReplyDelete

  4. Is it accurate to say that you are intrigued to learn Python Coaching in Greater Noida? You are in ideal spot to start learning of the course Python Coaching In Greater Noida. Python is the most mainstream programming language which picked by various individuals in these days.You may locate a selective preparing program in the area and work with the live venture in the field. The Python Coaching In Greater Noida gives a testament to all up-and-comers the individuals who complete training.

    Best Python Coaching in Greater Noida

    Best Python Coaching institute in Greater Noida

    Python Coaching centre in Greater Noida

    ReplyDelete
  5. Your info is really amazing with impressive content..Excellent blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog..
    If you are looking for any Data science Related information please visit our website data science institutes in bangalore page!

    ReplyDelete
  6. This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.

    Artificial Intelligence Certification Course
    Java Certification Course
    AWS Certification Course
    Machine Learning Certification Course
    Data Science Certification Course
    DevOps Certification Course

    ReplyDelete
  7. Thank you for posting informative insights, I think we have got some more information to share with! Do check out
    oracle training in chennai and let us know your thoughts. Let’s have great learning!

    ReplyDelete
  8. The best source for assignment writing help on a variety of areas, including database assignments, programming assignments, accounting assignments, statistics assignment help, economics assignment help, and java assignment help in Australia, is Online Assignment Expert. Our knowledgeable assistants collaborated with the expert team and completed tasks flawlessly, following all university requirements and following the right structure. You can get all of these assignment assistance services for a very reasonable cost.

    ReplyDelete
  9. Exceptional resource for Java assignment help. MyAssignmentServices provides expert guidance and support to help students excel in their Java programming studies. Highly recommend checking them out for top-notch assistance. Their dedication to excellence and commitment to delivering timely results make them a trusted choice for academic success. Explore their services today and take your Java assignments to the next level.

    ReplyDelete

Hi ! I'm Raad. And this my personal blog. Welcome to my blog.