Core Java: Interview Questions

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

List of OOP Concepts in Java

1. Abstraction. Abstraction means using simple things to represent complexity. 2. Encapsulation. This is the practice of keeping fields within a class private, then providing access to them via public methods. 3. Inheritance. It lets programmers create new classes that share some of the attributes of existing classes. 4. Polymorphism. One form of polymorphism in Java is method overloading. A single method name might work in different ways depending on what arguments are passed to it. The other form is method overriding. The child class can use the OOP polymorphism concept to override a method of its parent class. That allows a programmer to use one method in different ways depending on whether it's invoked by an object of the parent class or an object of the child class.

How many types of memory areas are allocated by JVM?(深入理解JVM)

1. Class(Method) Area 2.Heap 3. Stack 4. Program Counter Register 5. Native Method Stack

How many types of constructors are used in Java?

Default Constructor is the one that does not accept any value. The default constructor is mainly used to initialize the instance variable with the default values. Parameterized Constructor: The parameterized constructor is the one that can initialize the instance variables with the given values.

What is the difference between JDK, JRE, and JVM

JVM stands for Java Virtual Machine; it is an abstract machine which provides the runtime environment in which Java bytecode can be executed. JRE stands for Java Runtime Environment. It is the implementation of JVM. JDK is an acronym for Java Development Kit. It is a software development environment which is used to develop Java applications and applets. It contains JRE + development tools.

Java virtual machine

Java Virtual Machine is a virtual machine that enables the computer to run the Java program. JVM acts like a run-time engine which calls the main method present in the Java code. JVM is the specification which must be implemented in the computer system. The Java code is compiled by JVM to be a Bytecode which is machine independent and close to the native code.

What is Java?(features of Java Programming language)

Java is the high-level, object-oriented, robust, secure programming language, platform-independent, high performance, Multithreaded, and portable programming language.

What if the static modifier is removed from the signature of the main method? 如果静态修饰符从主方法的签名中删除了会怎样?

Program compiles. However, at runtime, It throws an error "NoSuchMethodError."

What are the various access specifiers in Java? 访问说明符

Public, Protected(same package, sub-class or within the same class), Default(within the package only), Private(with in the class only)

What is the static block?

Static block is used to initialize the static data member. It is executed before the main method, at the time of classloading. Example: class A2{ static{System.out.println("static block is invoked");} psvm{} }

What is an object?

The Object is the real-time entity having some state and behavior. In Java, Object is an instance of the class having the instance variables as the state of the object and the methods as the behavior of the object. The object of a class can be created by using the new keyword.

What gives Java its 'write once and run anywhere' nature?

The bytecode. Java compiler converts the Java programs into the class file (Byte Code) which is the intermediate language between source code and machine code. This bytecode is not platform specific and can be executed on any computer.

What is the constructor?

The constructor can be defined as the special type of method that is used to initialize the state of an object. It is invoked when the class is instantiated, and the memory is allocated for the object.

What is the default value of the local variables? 局部变量的默认值是多少?

The local variables are not initialized to any default value, neither primitives nor object references. 本地变量未初始化为任何默认值; 既不是原语也不是对象引用。

What is the purpose of static methods and variables?

The methods or variables defined as static are shared among all the objects of the class. The static variables are stored in the class area, and we do not need to create the object to access such variables.

What are the restrictions that are applied to the Java static methods?

The static method can not use non-static data member or call the non-static method directly. this and super cannot be used in static context as they are non-static.

Does constructor return any value?

yes, The constructor implicitly returns the current instance of the class.


Set pelajaran terkait

Quiz 3 dividend discount models to value stocks

View Set

the Fronde in Bordeaux - the Ormee

View Set

Topic 2 Lesson 6 New Ways of Life

View Set

NUR 212: Chapter 89 Drug Therapy for UTI's

View Set

Research in Public Elementary and Secondary Schools - SBE

View Set