java面试题每日10问(1)
创始人
2024-05-08 00:51:29
0

Core Java: Basics of Java Interview Questions

1.What is Java?

  • Java is object-oriented, platform-independent, Multithreaded, and portable programming language.
  • it provides its own JRE and API.

2.What is the difference between JDK, JRE, and JVM?

在这里插入图片描述
JVM

  • Java Virtual Machine provides the runtime environment
  • JVM converts Java bytecode into machine language

JRE

  • Java Runtime Environment make java program to run
  • It contains the class libraries, loader class, and JVM.
  • JRE provide the runtime environment.

JDK

  • Java Development Kit contains tools can write Java programs and JRE to execute them.
  • It includes a compiler, Java application launcher
  • JDK includ JRE and JVM

3. What is Object-Oriented?

  • object-oriented programming is about creating objects that contain both data and methods.
  • advantages
    • OOP is faster and easier to execute
    • we don’t need to repeat
    • The code easier to maintain, modify and debug
    • OOP can reuse before code and reduce development time

4. What is Multithreaded?

  • programs can deal with many tasks at once
  • programs doesn’t occupy memory for each thread and share a common memory area.

5.What are the various access specifiers in Java?

  • access specifiers are used to define the access scope of the method, class, or a variable
    Public
    The classes, methods, or variables are defined as public,
    it can be accessed by any class or method.
    Protected
    Protected can be accessed by the class of the same package, or by the sub-class of this class, or within the same class.
    Default
    Default are accessible within the package only.
    Private
    private can be accessed within the class only.

6. 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 is the part of the class and not of the object.
  • The static variables are stored in the class area, and we do not need to create the object to access such variables.

7. What are the advantages of Packages in Java?

  1. Packages avoid the name clashes.
  2. The Package provides easier access control.
  3. We can also have the hidden classes that are not visible outside and used by the package.
  4. It is easier to locate the related classes.

Core Java - OOPs Concepts: Initial OOPs Interview Questions

8. What is an object?

  • Java object is a member (instance) of a Java class
  • Each object has an identity, a behavior and a state.
  • The state of the object is stored in fields (variables), methods (functions) display the object’s behavior.
  • In Java, an object is created using the keyword “new”.

9.What is the difference between an object-oriented programming language and object-based programming language?

Object Based Languages

  • Object based languages supports the usage of object and encapsulation.
  • They does not support inheritance or, polymorphism or, both.
  • Object based languages does not supports built-in objects.
  • Javascript, VB are the examples of object bases languages.
    Object Oriented Languages
  • Object Oriented Languages supports all the features of Oops including inheritance and polymorphism.
  • They support built-in objects.
  • C#, Java, VB. Net are the examples of object oriented languages.

Core Java - OOPs Concepts: Constructor Interview Questions

10.What is the constructor?

  • The constructor is special method that is used to initialize the object.
  • It is invoked when the class is instantiated, and the memory is allocated for the object.
  • Every time, an object is created using the new keyword, the default constructor of the class is called.
  • The name of the constructor must be similar to the class name.
  • The constructor must not have an explicit return type.

相关内容

热门资讯

监控摄像头接入GB28181平... 流程简介将监控摄像头的视频在网站和APP中直播,要解决的几个问题是:1&...
Windows10添加群晖磁盘... 在使用群晖NAS时,我们需要通过本地映射的方式把NAS映射成本地的一块磁盘使用。 通过...
protocol buffer... 目录 目录 什么是protocol buffer 1.protobuf 1.1安装  1.2使用...
在Word、WPS中插入AxM... 引言 我最近需要写一些文章,在排版时发现AxMath插入的公式竟然会导致行间距异常&#...
【PdgCntEditor】解... 一、问题背景 大部分的图书对应的PDF,目录中的页码并非PDF中直接索引的页码...
Fluent中创建监测点 1 概述某些仿真问题,需要创建监测点,用于获取空间定点的数据࿰...
educoder数据结构与算法...                                                   ...
MySQL下载和安装(Wind... 前言:刚换了一台电脑,里面所有东西都需要重新配置,习惯了所...
修复 爱普生 EPSON L4... L4151 L4153 L4156 L4158 L4163 L4165 L4166 L4168 L4...
MFC文件操作  MFC提供了一个文件操作的基类CFile,这个类提供了一个没有缓存的二进制格式的磁盘...