Skip to content

Latest commit

 

History

History
377 lines (313 loc) · 15.5 KB

Java_note.md

File metadata and controls

377 lines (313 loc) · 15.5 KB

1)What is java? Ans-> java is a very Simple ,high level,secured,multithreaded,platform independent,object oriented programming language, it was developed by james Gosling in sun microSystem in 1990's for developing internet applications. it is first version is released in january 23,1996.

2)why java ? Ans-> java programming language mainly designed to develop internet application by providing platform independency, using java we can develope both standalone and internet application .

3)who invented java ? Ans-> java is invented by a Scientist James Gosling in Sun Microsystem .For developing internet application.

4)what is the abbreviation of java? Ans-> There is no abbreviation for java .The Development Team of java has just Chosen this name .The name java Specifically doesn't have any meaning rather it refers to the Hot Aromatic drink Coffee,This reason Java programming language icon is coffee cup.

5)What is Source Code ? Ans-> Source code is the set of instructions and statements written by a programmer using a computer programming language. This code is later translated into machine language by a compiler. The translated code is referred to as object code

6)What is Compiled Code ? Ans-> Compiler generated program that is Converted from Source Code is called Compiled Code.

7)What is Compiler ? Ans-> The compiler is software that converts a program written in a high-level language (Source Language) to a low-level language (Object/Target/Machine Language/0’s, 1’s) at Once.

8)What is Interpreter? Ans-> it is also translate the program that Convert Source code in to Machine Language but Line By Line.

9)What is Compilation ? Ans-> It is a Process of translating Source Code into Compiled Code.

10)What is Compilation ? Ans-> It is a Process of running Compiled Code to get output.

11)why java is called programming language ? Ans-> java is called programming language because to execute java programs java has it's own syntax and semantics for developing new programs.

12)why java called platform ? Ans-> java is called platform because to execute java programs java has its own running platform called jvm. java programs are executed by jvm.

13)why java is called Technology ? Ans-> java is called Technology because it provides many Predefined for Simplifying java projects development.

14)Why the name OAK renamed to JAVA ? Ans-> They were unable to register this programming language with name OAK ,because already some other products is registered. with the same name ,So they renamed to java.

15)Who invented Java Programming? a) Guido van Rossum b) James Gosling c) Dennis Ritchie d) Bjarne Stroustrup Answer: b Explanation: Java programming was developed by James Gosling at Sun Microsystems in 1995. James Gosling is well known as the father of Java.

16)Which statement is true about Java? a) Java is a sequence-dependent programming language b) Java is a code dependent programming language c) Java is a platform-dependent programming language d) Java is a platform-independent programming language Answer: d Explanation: Java is called ‘Platform Independent Language’ as it primarily works on the principle of ‘compile once, run everywhere’.

17)Which component is used to compile, debug and execute the java programs? a) JRE b) JIT c) JDK d) JVM Answer: c Explanation: JDK is a core component of Java Environment and provides all the tools, executables and binaries required to compile, debug and execute a Java Program.

18)Which one of the following is not a Java feature? a) Object-oriented b) Use of pointers c) Portable d) Dynamic and Extensible

Answer: b

19)Which of these cannot be used for a variable name in Java? a) identifier & keyword b) identifier c) keyword d) none of the mentioned

Answer: c Explanation: Keywords are specially reserved words that can not be used for naming a user-defined variable, for example: class, int, for, etc.

20)What is the extension of java code files? a) .js b) .txt c) .class d) .java

Answer: d Explanation: Java files have .java extension.

21)Which environment variable is used to set the java path? a) MAVEN_Path b) JavaPATH c) JAVA d) JAVA_HOME

Answer: d Explanation: JAVA_HOME is used to store a path to the java installation.

22)The \u0021 article referred to as a a) Unicode escape sequence b) Octal escape c) Hexadecimal d) Line feed Answer: (a) Unicode escape sequence Explanation: In Java, Unicode characters can be used in string literals, comments, and commands, and are expressed by Unicode Escape Sequences. A Unicode escape sequence is made up of the following articles: A backslash '' (ASCII character 92) A 'u' (ASCII 117) One or more additional 'u' characters that are optional. A four hexadecimal digits (a character from 0 - 9 or a-f or A-F) Hence, the correct answer is the option (a).

23)Which of the following is a valid declaration of a char? a) char ch = '\utea'; b) char ca = 'tea'; c) char cr = \u0223; d) char cc = '\itea'; Answer: (a) char ch = '\utea'; A char literal may contain a Unicode character (UTF-16). We can directly use these characters only if our file system allows us, else use a Unicode escape (\u) such as "\u02tee". The char literals are always declared in single quotes ('). The option b, c, and d, are not valid because: In the option b), to make a String valid char literal, we should add prefix "\u" in the string. In the option c), single quotes are not present. In the option d), "\i" is used in place of "\u." Hence, the correct answer is the option (a).

24)Which of the following tool is used to generate API documentation in HTML format from doc comments in source code? a) javap tool b) javaw command c) Javadoc tool d) javah command Answer: (c) Javadoc tool Explanation: The Javadoc is a tool that is used to generate API documentation in HTML format from the Java source files. In other words, it is a program (tool) that reads a collection of source files into an internal form.

25)JDK stands for ____. a)Java development kit b)Java deployment kit c)JavaScript deployment kit d)None of these Answer: A) Java development kit Explanation: JDK stands for Java Development Kit. It is a platform to develop and run Java applications.

26)JRE stands for ___. a)Java run ecosystem b)JDK runtime Environment c)Java Runtime Environment d)None of these Answer: C) Java Runtime Environment Explanation: JRE stands for Java Runtime Environment which provides an environment to run a java program.

27)What makes the Java platform independent?

a)Advanced programming language b)It uses bytecode for execution c)Class compilation d)All of these Answer: B) It uses bytecode for execution Explanation: In Java, programs are compiled into byte code and that byte code is platform-independent.

28)Can we keep a different name for the java class name and java file name? a)Yes b)No Answer: A) Yes Explanation: Yes, we can keep different names for java filename and java class name if and only if the class is not public.

29). Can we write a program without a main method in Java? a)Yes b)No Answer: A) Yes

30)What is the entry point of a program in Java? a)main() method b)The first line of code c)Last line of code d)main class Answer: A) main() method Explanation: Generally, the main() method is treated as the point where the flow of code starts.

  1. Can the main() method be overloaded in Java? a)Yes b)No Answer: A) Yes Explanation:Yes, We can overload the main method in java but JVM only calls the original main method, it will never call our overloaded main method.

  2. Can the main() method be overloaded in Java? a)Yes b)No Answer: A) Yes Explanation: Yes, We can overload the main method in java but JVM only calls the original main method, it will never call our overloaded main method.

33)What is the use of javac command? a)Execute a java program. b)Debug a java program. c)interpret a java program. d)Compile a java program. Answer: d) Compile a java program. Explanation: the javac command in java compiles a program from a command prompt.it reads a java Source program from a text file and creates a compiled java class file.

34)Difference between JDK,JRE and JVM ? Ans-> jvm is a subset of JRE ,and JRE is the subset of JDK ,when we Installed JDK ,JRE is also installed automatically . JRE software is avilable as a separate pack ,so we can install JRE alone. JDK has both Compiler and JVM ,so using JDK we can develop ,compiler and execute new java application and also we can modify ,compiler and execute already developed applications .JRE has only JVM. 35)How many features in java and what are they ? Ans-> 14 features. a-Simple. b-Secure. c-Robust. d-Protable. e-Architecture Neutral . f-Object oriented. g-Multithread. h-High performance. i-Distributed. j-Dynamic. k-Byte Coded. l-Interpreted. m-Garbage Collected. n-Open Source. 36)What are the Programming element ? Ans-> java support 10 basic programming elements. a-Module. b-Class. c-Interface. d-enum. e-annotation. f-package. g-Variable. h-Method. i-Constructor. j-Block. 38)why class is essential ? Ans-> class is essential because java is an object oriented programming language ,every program must start with a class and moreover only class allows us to define method with logic.

39)What is main method ? Ans-> Main method is user-defined method with pre-defined prototype.

40)Why main method ? Ans-> main method is essential because java program execution starts with main method jvm can execute only main method from a class.

41)what is the syntax of main method ? Ans-> public static void main(String args[]){}

42)why main method has public ? Ans-> To be accessed by JVM software from outside of our project directory min method must has public keyword .

43)why main method has static ? Ans-> To access and execute main method logic without creating object ,main method has static keyword.

44)Why main method return type is void ? Ans-> Returning value from the main method is useless because the value returning from jvm main method will be return to jvm ,Jvm will not do any work with this returned value ,hence to stop returning value from main method it must be void .

45)Why main method name is main ? Ans-> According to coding standards main method name is choosen as main because it is the initial point of class execution , any initial poiint generally called as main .

  1. Why main method has parameter ? Ans-> The main method has parameter to receive input values from enduser at the time of program execution from command line.

  2. Why main method parameter is Array? Ans-> To allow end-user to pass multiple value ?

  3. why main method parameter type is String[] ? Ans-> Any value sending from keyboard will passed into program as string type by us,and moreover only values can be represented in terms of string and further it can be converted to its original type,hence SUN choosen main method parameter type as String[].

49)Why main method parameter name is args ? Ans-> The input values sending to a method parameter is technically called as arguement ,so it is the short -cut name of arguement.

50)Can we change the parts of main method ? Ans-> Except args we are not allowed to change or remove the main method other parts.

51)Why System.out.println() is essential ? Ans-> System.out.println() is essential because in java we can print any message or data on console by this statement.

  1. What are the java printing statements ? Ans-> java has 3 printing statements to display a. System.out.println(); b. System.out.print(); c. System.out.printf(); 53)what is user defined method ? Ans-> Developer defined method is called user -defined method.

54)What is pre-defined method ? Ans-> This methods may be developed by suns developer or some other developer is called pre-defined method. 55)where will we use java? Ans-> we use java for developing below different types of application a.web application b.Enterprise application c.desktop application d.mobile application e.gaming application f.Robotic application,Automation testing g.IOT ,cloud computing,Big data,Hadoop

56)when should we use java ,python and C? Ans-> For java:when developing enterprise application ,where we need devlope user interface and business money trasactions, we will use java. For Example : Amazon,Flipcart ,bank app .

  For Python:for developing data science ,mechine learning ,AI application python is used for developing recomendations
             based user search data we must use python.
  For c:We use c for developing system level and application level software which are stand alone and platform dependent
           ex. os,Drivers and ms office etc.

57)what is platform dependent application? Ans-> The programming language that is compiled in one os and it cannot run in another operating system then application is called platform dependent application.

58)What is platform independent application? Ans-> If the compiled code is able to run in different appllication is called platform-independent application. The programming language that is used to develope this application is called platform-independent programming language. Example: java 59)What is stand alone application and types ? Ans-> The application that can only be executed in local call , is called stand-alone application. it means a program that can be accessible only one computer in which it is installed by single user .Stand alone applications cannot accessible form remote user via internet. types 1. CUI 2. GUI 60)What is internet application and it's type ? Ans-> Internet application is a multiple computers and multiple user appllication .it means a program i.e. accessible locally and remotely from different computers through the network call by multiple users at a time is called internet application. it is of two types :- a.Client-side executing applications b.server-side executing applications

61)what is the main features of programming language to develope internet application? Ans-> Platform independency because an internet application must run in all operating systems irrespective of where it is compiled.

62)Why c and c++ programming language can not support internet application development? Ans-> Because they are platform dependent .

63)why c and c++ programming language were developed as platform dependent application why not as platform independent application? Ans-> By the times c/c++ programming languages are developed there was no internet ,platform independency features is only required for developing internet applications. 64)why c/c++ program compiled code can not execute in all os? Ans-> in these programming languages the compiled code is machine language which is understandable only by the current os.Thus the compiled code cannot be executed in different operating system.Due to this reason these languages are considered as platform dependent programming languages.

65)what is the need of proramming language ?

Every programming language is meant for developing a program to implement an operation to be perform by a computer . Basically programming language are inverted for automatic bussiness operations to be performed by a computer. Automation will give several benefits over manual operations they are, a.24*7 ,365 days we run ourcbussiness. b.we can have good relation with customer. c.Secured ,accurated,efficient fast transaction .

  1. what are the language fundamentals ? 1.Data type (literal ,variables and object )-Storing values. 2.Operators-for performing validation & calculation . 3.Control flow Statement- for controling flow of execution . 4.Exception handling Statements-for throwing and catching and exception. The above 4 concepts are technically called as language fundamentals.