Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 8
1) What is Java? Who invented it?
Ans) Java is a programming language developed at Sun
Microsystems by James Arthur Gosling, a Canadian computer scientist, as its lead engineer. He is best known as the Father of the Java Programming Language. It was originally called Oak. 2) Tell about the Java language. Ans)Java is a robust, general-purpose, high-level programming language and a powerful software platform. 3) How many types of programs are written in Java? Ans)Programs that are written in Java are generally categorized into two groups, namely- •Applets:Applets or Java Applets are small programs that remain embedded in a web page and are run on the viewer's machine in a secured manner by Java compatible browsers. It cannot access the resource of the local machine. Using applets, you can do anything ranging from animations to complete games and utilities that can be executed over the Internet. • Applications - These are the programs which are executed by the JVM and it does not depend on anything else other than JVM . These can be executed in any system containing JVM and it can either have a Command Line Interface or Graphical User Interface. It does not depend on the specifications but can access system resources. 4) How are Java programs compiled? Ans) Java is a platform independent language which indicates that it is possible to write a program in a computer but execute it in any type of machine. This is because the way Java works is different from most other high level languages. Whenever you install Java in your computer you are actually installing the Java Virtual Machine (JVM) in it. YOU CAN IMAGINE THE JVM AS A PSEUDO MICROPROCESSOR THAT IS IMPLEMENTED IN SOFTWARE, AND RUNS USING THE CAPABILITIES PROVIDED BY YOUR OPERATING SYSTEM AND COMPUTER HARDWARE. Thus JVM can be thought to be a computer (of course virtual) inside a physical computer. The JVM recognizes only one language called the Bytecode. Whenever you write a Java program and compile it, it gets converted to Bytecode. Thus any machine irrespective of the underlying hardware and operating system having the JVM installed will have the bytecode being recognized and executed. 5) WHAT IS JAVA SOURCE CODE? Ans) A SET OF INSTRUCTIONS WRITTEN IN A PROGRAMMING LANGUAGE IS CALLED A PROGRAM. A program is called a source code. SOURCE CODE IS THE FUNDAMENTAL COMPONENT OF A COMPUTER PROGRAM THAT IS CREATED BY A PROGRAMMER. It can be read and easily understood by a human being. WHEN A PROGRAMMER TYPES a SEQUENCE OF JAVA LANGUAGE STATEMENTS INTO WINDOWS NOTEPAD or BlueJ Editor, for example, and saves the sequence as a text file, the text file is said to contain the source code . THE SOURCE CODE FILE IN JAVA HAD the .Java extension. The name of the file will be same as the class name, For example, if the class name in the source code is MyClass, its file-name will be MyClass.java. 6)WHAT IS BYTE CODE? ANS) BYTE CODE IS THE COMPILED FORM OF SOURCE CODE. A PROGRAMMER WRITES A PROGRAM IN THE JAVA LANGUAGE THAT USE Predefined SOFTWARE PACKAGES OF JAVA API, WHICH IS A COLLECTION OF PREWRITTEN PACKAGES, CLASSES,INTERFACES . THEN THAT SOURCE CODE IS TRANSLATED TO A LANGUAGE BY THE COMPILER CALLED THE BYTECODE WHICH CAN BE UNDERSTOOD BY THE JVM. 7) What makes Java highly portable? Ans) The byte code is a set of pseudo machine language instructions that is understood by the Java Virtual Machine and is independent of the underlying hardware. it is in a form that can be executed on the Java Virtual Machine (JVM), the core of the Java runtime system. The byte code file is recognized by the JVM and can be interpreted by it for execution. Thus wherever you have installed the JVM, irrespective of the underlying hardware and operating system, it can interpret and execute the byte code file. This makes Java highly portable. 8)What is the Java compiler? Ans) The name of the Java compiler is javac.exe in windows. This compiler converts a source code written in the Java language to alter it to a byte code file. The byte code file is a new file that is created from the source code, which has the same name but with .class extension. For example, if the name of the source code file is MyClass.java, upon compilation a new byte code file is created named MyClass.class. 9) What is object code? Ans) Unlike Java, which upon compilation produces byte code, other languages generally produce object code. Object Code produces recognizable and executable machine code. It basically contains a set of instruction codes (that got translated from the source code) that is understood by a computer at the lowest hardware level. It is usually produced by a compiler that reads some high level language source instructions and translates them into equivalent machine language instructions. Since Java does not execute on the physical computer but on the JVM, Thus byte code is the object code for JVM . 10) What is JVM? Ans) JVM or Java Virtual Machine is a microprocessor that is implemented in software and runs using the capabilities provided by your operating system and computer hardware. Since the JVM is not a real microprocessor, the Java bytecode is interpreted, rather than executed directly in the native machine instructions of the host computer. Thus to run a program written in Java you need to have the JVM installed in that machine. You get JVM which is compatible with almost all major operating systems. You write a program in Java (Source Code) compile it to convert it to a language understood by the JVM called bytecode, which now can be interpreted to run on the JVM. This makes Java compatible with all popular operating systems. Programs written in other languages (like C++) when compiled get converted to machine language, which may then be executed. But conversion to machine language makes it machine dependent and also dependent on the underlying hardware. This is the reason why a software developed using C++ for a Windows machine will run only on a Windows machine and not on a Linux machine. But a Java program developed, when compiled, converts it to bytecode, which is practically free of the underlying hardware or software. The bytecode file is recognized by the JVM and can be interpreted by it for execution. Thus wherever you have installed the JVM, irrespective of the underlying hardware and operating system it can interpret and execute the bytecode file. This makes Java highly portable. 11) how is Java simple? Ans) Java is simple to learn. This is because it was designed with a small number of language constructs so that programmers could learn it quickly Its syntax is based on C++ and is therefore easy to learn after C++. However, the syntax is such that even if it is being learnt for the firs time, it is still very easy to pick. This is because it eliminates severa language features available in C++ that are associated with programming practices or are rarely used . There is no need to remove unreferenced objects because ther is Automatic Garbage Collection in Java. 12) How is Java robust? Ans) The term robust means strong or vigorous. Java uses some strong design measures to eliminate certain types of programming errors. It allows extensive compile-time error checking. Therefore, most of the errors will be trapped and need to be rectified during compilation. Apart from this Java also uses strong memory management. This is because it lacks pointers, thereby, eliminating the possibility of overwriting memory and corrupting data. In addition, its automatic memory management (garbage collection) eliminates memory leaks and other problems associated with dynamic memory allocation/de-allocation. Other features such as exception handling and type checking mechanism is also the reason for it to be robust. 13) How is Java secured? Ans) Java is designed to be secure in a networked environment. It is designed with multiple layers of security countermeasures embedded in the compiler, runtime system, and in browsers that support Java. These countermeasures make Java inherently more secure for developing any type of trusted application software. The Java run-time environment uses a byte code verification process to ensure that network does not violate Java security constraints. 14) How is Java object oriented? Ans) . In terms of software, object oriented means we organize our software as a combination of different types of objects that incorporates both data (characteristics) and method (behaviour). This makes Java to simplify software development and maintenance by providing some rules. Thus all basic principles of Object Oriented Programming are followed in Java . 15) How is Java architecture neutral? Ans) In Java there are no implementation dependent features. In most of other languages you need to know features that are hardware or OS dependent. For example in a high-level language called C the int data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes of memory for 64-bit architecture. But in Java, no such knowledge is needed. 16) Explain multi threading as a feature of Java? Ans) Multithreading is a process of executing multiple threads simultaneously. Thread is basically a lightweight sub-process, the smallest unit of processing. The main purpose of multithreading in Java is to provide simultaneous execution of two or more parts of a program to utilize the CPU to the maximum. A multithreaded Java program contains two or more parts that can run concurrently 17 What is thread? Ans) Thread is basically a lightweight sub-process, the smallest unit of processing.