的re are two important factors that Python is known as a 郎uage for beginners:
• 易于编码
Comparing Python with other programming 郎uages such as 爪哇,C和C ++等等,Python非常容易直接编写代码。对于初学者来说,他们更容易学习 python语法 在短短几个小时内。但是,要精通Python,需要学习其所有高级概念,软件包和模块,这可能需要一些时间。简而言之,我们可以说Python是一种程序员友好的语言。
Another great thing regarding Python is that it is open-source. Since it is open-source, 这个 means that source code is available 上市ly. You can download it, modify it, use it, 和 distribute it without permission from its developers. This mechanism is known as FLOSS(免费/自由和开源软件)。作为开源,大多数开发人员都朝着改善Python的目标迈进。
Python 郎uage is known as a portable programming 郎uage. 例如, assume you have written a Python code for windows, 和 you want to run 这个 code on any other platform such as Linux, Unix or Mac then you don't need to change it, it can be efficiently run on other platforms. This means that you don't need to write different code for different types of machines. It makes Python a cross-platform 郎uage.
However, it is important that you avoid any system-dependent features in 这个 case.
Python is an extensible programming 郎uage. You can write Python code into C或C ++ 郎uage 和 also compile in C/C++. This feature defines that Python can be extended to other 郎uages.
• 强大的- 强大的 means strong. 爪哇 programs are robust 和 do not crash as easily as 和 C 'and' C ++ 'programs. 的re are two reasons for 这个. Firstly, 爪哇 has got excellent inbuilt exception handling features 和 secondly its memory management facility.
大多数“ C”和“ C ++”程序由于未分配足够的内存而中途崩溃。 爪哇不会出现此类问题,因为用户不必在Java中分配或处理内存。一切都会由JVM处理。
类 Person
{String name;int age;虚空 talk();//member of class虚空 eat();}
Person Jacob= 新 Person();//Creating object 'Jacob'
Jacob. talk();//accessing member of class
Jacob. eat();
BYTE代码是由JVM解释的中间级代码。它不能在计算机上直接执行。 BYTE代码是Java程序和操作系统(OS)的机器代码之间的中介程序代码,可在‘.class’ file. A ‘.class’编译Java程序或应用程序时将生成文件。对于任何操作系统,BYTE代码均相同,但每个操作系统上的机器代码均不同。
编写和编译Java程序时,它会创建一个‘.class’ file which consists of byte code instruction understandable to 虚拟机. This class file is system independent. Every system 郎uage has its own 虚拟机. So, 虚拟机 converts 这个 byte code into machine 郎uage which is understandable to that particular system. This is what gives 爪哇 ‘编写一次即可在任何地方运行’ nature. 的 爪哇 platform is an independent programming 郎uage.
14) What is 上市 静态的 虚空 main(String args[]) in 爪哇?
线 上市 静态的 虚空 main(String[] args) 定义方法main。从概念上讲,它类似于C / C ++中的main()函数。
在Java中,the 主要() is the entry point for any 爪哇 program. A 爪哇 program can have any number of classes but only one of them must include a method to initiate the execution. 线 includes the following terms:
爪哇 is not 100% object-oriented because it supports non-primitive data types which are not objects. Concepts like 多态性, inheritance, abstraction, mainly OOPs concepts make 爪哇 an object-oriented 郎uage. However, it doesn’支持所有OOP概念,例如多重继承。
A 包 represents a directory or a container that stores related group of classes 和 interfaces. 的 functionality of the objects decides how they are grouped.
• 爪哇.lang: ‘lang’ stands for 郎uage. This 包 got primary classes 和 interfaces essential for developing a basic program.
• 爪哇.util: ‘util' stands for utility. This 包 contains useful classes 和 interfaces like the stack, LinkedList, 向量, 数组, 等等 的 classes are called collections.
• 爪哇.io: ‘io’ stands for ‘input 和 output’. This 包 contains streams. A stream represents the flow of data from one place to another.
(ii)用户定义的程序包
就像内置包一样,用户也可以创建自己的包。这样的软件包称为用户定义的软件包。要创建一个包,一个关键字‘package’ is used.
例如-
包 包name;//to create 包包 包name.subpackagename;//to create sub-package in a 包
class Noname{上市 静态的虚空main(String args[]){
System.out.println("Hello from 教程伴侣");}}
滚动⇀
If you save 这个 program by .java only, you have to compile it by 爪哇c .java 和 run it by 爪哇 Noname.
34)包装类是什么?
As the name suggests, wrapper classes are used to wrap the primitive data type into an object of that particular class. In simple words, wrapper classes are used to convert 爪哇 primitives into the reference types (objects). 的y are typically the way of object representation of all eight primitive commonly used in 爪哇. 在Java中,all the wrapper classes are immutable 和 final.
注意:从Java 5开始,原语会自动转换为对象。此过程称为自动装箱。
关于集合的Java面试问题
35)Java中的收集框架是什么?
在Java中,a collection framework is basically an architecture consisting of classes 和 interfaces. It is used to store 和 manipulate data as objects. It includes many classes like 数组List, 向量, 叠放, HashSet, 等等 和 interfaces like List, Queue, Set, 等等 Using collections, we can perform various functions such as searching, sorting, insertion, deletion, manipulation, 等等
在Java中,a collection framework typically includes 接口,类和方法.
36)什么是类型转换?
Typecasting is the process of assigning one data type variable to another data type variable. However, 这个 concept does not apply to 布尔数据类型s. 的re are basically two types of typecasting:
In C ++ by default, 数组s are created on 静态的 memory unless pointers are used to create them. 在Java中,Arrays are created on dynamic memory which means that the memory is allotted at runtime by 虚拟机. 的re is no use of 静态的 memory in 爪哇. Everything (i.e., variable, array, object, 等等) is created on dynamic memory only.
在Java中,looping allows programmers to execute a statement or a block of statement repeatedly. It typically enables programmers to control the flow of execution by repeatedly performing a set of statements as long as the continuity condition remains 真正.
An infinite loop is a set of instructions in 爪哇 that loops infinitely when a condition does not satisfy. This type of loop is typically a result of a programming 错误. An infinite loop will terminate automatically if we close the application or we can use “ctrl + c”立即终止。
例
上市class InfiniteForLoopDemo
{上市静态的虚空 main(String[] arg){for(;;)System.out.println("Hello from 教程伴侣.");}}
滚动⇀
43) What is the main difference between 打破 和 继续 statement? Explain with examples.
在Java中,break 和 继续 are two important statements used with Loops. Let’s understand each:
打破
在循环中使用“ 打破”语句时,循环立即终止。它也可以与'switch'语句一起使用。
例: In 这个 example, Loop is terminated when the value of integer ‘i’ reaches 5.
Generally, a group of 烧焦acters is called a 'string'. But 这个 is not valid in 爪哇. 在Java中,a 串 is an object that represents a sequence of 烧焦acters. A class 爪哇.lang.String is used for creating a 串 object. An array of 烧焦acters works similarly to 爪哇 串s.
例如:
烧焦[] ch = {'t','u','t','o','r','i','a','l','s','m','a','t','e'};
String s = 新 String(ch);
滚动⇀
与:
String s = "同学";
滚动⇀
爪哇Soft人们已经用名称分别创建了一个类‘string’ in 爪哇.lang 包, with all the necessary methods to work with 串s.
45) How 串s are created in 爪哇?
的re are three common ways used to create a 串 in 爪哇:
(一世) We can create a 串 by assigning a group of 烧焦acters to a 串 type variable-
String s;
s = “tutorialsmate”
滚动⇀
前面的两个语句可以组合,并且可以写为:
String s = “tutorialsmate”;
滚动⇀
In 这个 case, 虚拟机 creates an object 和 store the 串 “tutorialsmate” in that object.
(ii) Another way, a 串 can be created by using a 新 operator-
String s = 新 String(“tutorialsmate”)
滚动⇀
(iii) 的 third way of creating the 串s is by converting the 烧焦acter array into 串s-
Now, create a 串 object by passing the array name like 这个:
String s = 新 String(arr);
滚动⇀
In 这个 case, all the 烧焦acters of the array are copied into the 串. If we do not want to copy all the 烧焦acters of the array into the 串, then we can specify the 烧焦acters that we need as below:
String s = 新 String(arr,2,3);
滚动⇀
Now, the 烧焦acters will be copied from the 2nd 烧焦acter of the array 和 there will be a total of 3 烧焦acters copied into the 串 s.
在Java中,constructor is a special kind of method commonly used to initialize the state of an object. It must have the same name as that of the class where it belongs. 什么时候ever a 新 object is created, a constructor corresponding to the class gets invoked. 的 constructor must not include an explicit return type.
参数化构造函数: 在Java中,a parameterized constructor is referred to as the constructor which can initialize the instance variables with the defined values. In other words, a constructor that cannot take the arguments is known as a parameterized constructor.
51)构造函数和方法之间有什么区别?
下表列出了构造函数和方法之间的一些重要区别:
建设者
方法
它用于初始化类的实例变量。
它用于任何通用处理或类。
构造函数’的名称和类名称必须相同。
方法的名称和类的名称可以相同或不同。
在创建对象时调用它。
创建对象后可以调用它。
每个对象仅调用一次。
可以在对象上多次调用它。
它被调用并自动执行。
仅当我们调用它时才执行它。
52)构造函数链接是什么意思?
在Java中,we can call a constructor from another constructor with respect to the existing object. However, it is only possible via legacy where a subclass is responsible for invoking the 超class' constructor first. 的 process is known as '构造函数链’。构造函数链可以包含任意数量的类。
可以使用两种方法执行构造函数链接:
(一世) Using 这个() within the current class (ii) Using 超() from the base class
54) What are the differences between 静态的 和 non-static methods in 爪哇?
的 main differences between 静态的 和 non-static methods are tabulated below:
静态方法
非静态方法
必须在方法名称之前使用它。
方法名称前不使用它。
的 静态的 method cannot access any non-static instance variable or method.
的 non-static method can access any 静态的 method or variable without creating an instance of the class.
的 静态的 method is called using the class (className.methodName).
与任何其他常规方法一样,调用非静态方法。
55)解释Java中的final关键字吗?
在Java中,a 'final' keyword is used as a non-access modifier. In simple words, it is a special keyword that is used to include restrictions on class, methods, 和 variables.
在Java中,Map is an object which maps unique keys to values. It is typically an interface but not a subset of the main collection interface 和 这个 is why it has different functionalities than other collection types.
Some important 烧焦acteristics of Map interface are listed below:
在Java中,‘super’ is a keyword that acts as a reference variable. It typically refers to the immediate parent class object. 什么时候ever the instance of a subclass is created, an instance of the parent class is also created which is referred by a 超 reference variable. 的 compiler will implicitly call 超() if there is no 超() or 这个() in the class constructor.
在Java中,this() 和 超() both are the special keywords commonly used to call constructors. However, there are some differences between them which are tabulated below:
这个()
超()
这个() is used to represent the current instance of a class.
超() is used to represent the current instance of a parent/base class.
这个() is used to access current class methods.
超() is used to access base class methods.
这个() is used to call the default constructor of the current class.
超() is used to call the default constructor of base/parent class.
这个() is used to point the current class context.
超() is used to point the parent class contexts.
这个() is used for differentiating local 和 instance variables when passed in the class constructor.
超() is used for initializing the base class variables within the derived class constructor.
上市class equalsDemo {上市静态的虚空 main(String args[]){String str1=新String("Hello from 教程伴侣");String str2 =新String("Hello from 教程伴侣");if(str1.equals(str2)){// when condition is 真正System.out.println("str1&str2的值相等。");}if(str1== str2){//when condition is 真正System.out.println("str1& str2 are referencing same object.");}else{// when condition is NOT 真正System.out.println("str1&str2引用了不同的对象。");}}}
什么时候 a child class (a single subclass) has two parent classes, it means that a child class inherits properties from multiple classes, 这个 is called multiple inheritance. 爪哇 does not support multiple inheritance because during runtime when there are two parent classes with the same method name, it becomes ambiguous 和 difficult for the compiler to determine which method to execute from the child class.
一个条件‘polymorphism’通常称为“many forms”, that means “一个界面,多种实现”. In simple words, 多态性 is a property of being capable to have various forms in different contexts –具体来说,允许诸如方法,对象或变量之类的实体采用几种形式。此机制仅适用于覆盖,不适用于重载。
的re are two types of 多态性s in 爪哇, namely "compile-time 多态性“和”run time 多态性”。 Run time 多态性 is also known as "动态方法分派”。
69)Java中的抽象是什么意思?
在Java中,Abstraction is the process of hiding the implementation details from the user 和 SHowing them only the essential things. It hides internal information 和 enables us to focus only on the concept of what an object can do rather than how it is doing.
方法 overloading is referred to as the compile-time 多态性. It may or may not involve inheritance.
73)通过方法重写您了解什么?
在Java中,method overriding allows a subclass to provide a specific implementation of a method which has already been offered with its parent class or 超class. In simple terms, the subclass retains the same method, the same name, the same type of parameter, 和 the same return type as a parent class. 方法 overriding is a concept of changing the existing behavior of the method.
方法 overriding is referred to as run time 多态性. It is necessary to have an inheritance in method overriding.
在Java中,aggregation can be explained as the relationship between two different classes where the aggregate class consists of a reference to the class it owns. In simple terms, all the objects have their own lifecycle but unlike the association, there is ownership. That means that child object cannot belong to any other parent object.
A Marker interface can be referred to as an interface that has no data member 和 member functions. In other words, an empty interface is defined as the Marker interface. 在Java中,the most common examples of the marker interface are Serializable, Cloneable, 等等
class Demo
{int i;上市 Demo(int a){
i=k;}上市 Demo(int a,int b){//body}}
滚动⇀
81)您对复制构造函数了解多少?
复制构造函数是成员函数,通常用于使用当前类的另一个对象初始化一个对象。
在Java中,there is no copy constructor. It does not even need a copy constructor concept because objects are passed by reference in 爪哇. That means that we can copy the values from one object to another. 爪哇 supports the following ways to copy the values of one object into another:
Batch processing is the process of grouping all related SQL statements into one batch so that they can be executed simultaneously rather than executed separately. Using 这个 concept in JDBC, we can execute multiple queries simultaneously which will result in increased performance.
在Java中,a servlet is a technology that works on the server-side. 的 servlet provides support for dynamic response 和 data persistence that helps increase the capacity of the webserver. We can also write custom servlets using the interfaces 和 classes of the 爪哇x.servlet和爪哇x.servlet.http 包s.
除了执行类,还有另一个子类,称为‘error’ which is derived from Throwable class. 的 exception class is divided into two main subclasses: IOException class 和 RuntimeException class. Both of these exceptions extend exception class whereas 错误s are further sub-divided into Virtual Machine 错误 和 Assertion 错误.
Synchronization 上一页ents memory consistency 错误s that may have occurred because of the inconsistent view of SHared memory. 什么时候 a method is synchronized, the thread holds the monitor of that particular method’的对象。如果另一个线程正在执行同步方法,则该线程将被阻塞,直到该线程释放监视器为止。
Please SHare 这个...