07_01Java(期末复习B)

本文详细梳理了Java期末复习的重点内容,包括B1至B7七个部分,覆盖关键知识点,帮助考生巩固理解。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

B1

package com.lenovo.s0620review;
/**
 * 定义一个公共类pub_test1,它含有两个float型变量fvar1和fvar2,
 * 还有一个int型的变量ivar1,pub_test1类中有一个方法sum(), 它将fvar1与ivar1的值相加,结果放在fvar2中。
 * 
 * @author Shinelon
 *
 */
public class pub_test1 {
   
    int ivar1;
    float fvar1, fvar2;

    public pub_test1(int ivar1, float fvar1, float fvar2) {
        this.ivar1 = ivar1;
        this.fvar1 = fvar1;
        this.fvar2 = fvar2;
    }

    public float sum() {
        fvar2 = fvar1 + ivar1;
        return fvar2;
    }

    public static void main(String args[]) {
        pub_test1 obj = new pub_test1(10, 15.5f, 335.5f);
        System.out.println("sum is:" + obj.sum());
    }
}

B2

package com.lenovo.s0620review;
/**
 * 设计一个类C(class C)实现接口A和接口B
 * @author Shinelon
 *
 */
interface A {
    void f1();

    int f2();
}

interface B {
    char b = 'b';
    String s = "abc";

    void f3();

    char f4();

    int f5(String s);
}

 class C implements A,B {
    public C() {
        // TODO Auto-generated constructor stub
        System.out.println("无参构造方法");
    }

    public void f1() {
        System.out.println("in f1");
    }

    public int f2() {
        System.out.println("in f2");
        int i = 1;
        return i;
    }

    public void 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值