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() {
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