JAVA003

解释下列程序(阐述数据位置,及存储值)

class   test{

  public  static  void main(String  args[]){

     String   s1=”hello”;

     String   s2=”hello”;

System.out.println(s1==s2);

String   s3=new  String(”hello”);

     String   s4= new  String(”hello”);

System.out.println(s3==s4);

int   x=300;

int   y=300;

      System.out.println(x==y);

      Integer  a=300;  

Integer  b=300;

      System.out.println(a==b);

Integer  c=-128;

Integer  d=-128;

      System.out.println(c==d);

Integer  e=127;

Integer  f=127;

      System.out.println(e==f);

Integer  g=-129;

Integer  h=-129;

      System.out.println(g==h);

Integer  i=128;

Integer  j=128;

      System.out.println(i==j);

}

}

运行结果是什么,说明了什么?

查看Integer源代码

 

编辑c程序【linux中运行】

typedef  char* String;

void  main(String  args[]){

       char  ch[]=”hello”;

       char  *p=”hello”;

      ch[0]=’H’;

      p[0]=’H’;

      printf(“%s,%s\n”,ch,p);

}

 

画上述程序内存布局

 

 

解释java程序运行结果

class b6{

public   static  void  main(String  args[]){

        byte  i=3;

        while(i++>2) i++;

        System.out.printf(“%d\n”,i);

}

}

 

解释程序运行结果

class b7{

public   static  void  main(String  args[]){

        int  i=3;

        while(i++<4) i++;

        System.out.printf(“%d\n”,i);

}

}

运行结果(         )

 

什么是封装?

 

 

继续右键—source,生成有参,无参构造函数

 

 

java怎么具体表示某个人?

先定义一个表示人的数据类型

再根据类型定义表示某个人的变量(对象),怎么创建对象(调用构造函数)

 

构造函数(构造器):

所有面向对象语言,有一种函数是没有返回类型,这个函数的名称一定和类的名称一样,这个函数就是构造函数,构造函数的作用,就是向操作系统申请内存(一定是在堆),申请的那块内存也称之为对象

 

class  any{

   public static void main(String[] args) {

      StuInfo  刘敏=null;   

      刘敏 =new StuInfo(10001, "whw");

      StuInfo  王宏伟=new StuInfo(10002, "whw");  

      System.out.println(刘敏.xm==王宏伟.xm);   

   }

}

 

 

画下列程序内存布局

class   test{

public static void main(String  args[]){

int  a[]=new  int[10];

Integer  b[]=new  Integer[10];

System.out.println(a[9]);

System.out.println(b[9]);

}

 

}

c和java的代码注释一样   //     /*  */

 

解释java代码块

double   d=1;

float  f=1;

f=d;

解释java代码块

double   d=1;

float  f=1.2;    //  f=1.2f

f=d;

java代码中浮点数默认按double类型处理,整数默认按int类型处理

 

每个人用代码输出  “\

翻译

 

三目运算符

System.out.println(   false  ?  1  :   2  );

 

int  max(int  a,  int  b){

return  a>b? a: b;

}

int  max(int  a,  int  b){

if(a>b)

 return a;

else

return b;

}

 

将如下代码用switch表示

int x = 30;

if( x == 10 ){

System.out.print("Value of X is 10");

}else if( x == 20 ){

System.out.print("Value of X is 20");

}else if( x == 30 ){

System.out.print("Value of X is 30");

}else{

System.out.print("This is else statement");

}

 

解释下列程序

class    Test{

static   int  a;

int  b;

}

class   Any{

   public   static  void  main(String  args[]){

        Test  t1=new Test();

        Test  t2=new  Test();

        t1.a=2;

        t1.b=1;

        t2.a=4;

        t2.b=6;

        System.out.println(t1.a+t1.b);

   }

}

 

 

解释程序运行结果

class b6{

public   static  void  main(String  args[]){

        byte  i=4;

        while(i++>2) i++;

        System.out.printf(“%d\n”,i);

}

}

 

 

java怎么具体表示5个人?

class Perosn{

   String  xm;

   Person(){}

   Person(String  xm) {   this.xm=xm;  }

}

Person   a=new Person[5];

Person   b[]=new Person[5];

b现在表示几个人?

Person  刘敏=new Person(“王宏伟”);

b[0]= 刘敏;

b[4]= new Person(“刘敏”);

b[3]= new Person(“王宏伟”);

b现在表示几个人?

b[2]= 刘敏;

b[3]= 刘敏;

b现在表示几个人?

 

构造函数(构造器):

构造函数的返回值是什么?

class   test{

public static void main(String  args[]){

Integer  b[]=new  Integer[10];

System.out.println(b[9]);

}

}

 

多态:

编译时多态( 函数重载Overload)

一个类中有多个同名的函数(函数声明形式肯定不一样)

运行时多态(函数重写Override):

父子类中有多个同名的函数(函数声明形式完全一样)

 

分析程序运行结果

 

 

 

构造函数能否重写?

 

构造函数能否重载?

和类同名的函数是不是都是构造函数?

 

什么是函数声明?什么是函数定义?

 

什么是抽象类?什么是抽象函数?

 

 

  有表及如下数据

 

xm

kcm

cj

张三

语文

60

张三

数学

90

李四

语文

70

李四

数学

90

王五

语文

80

王五

数学

100

 

写一个查询,显示结果如下

 

姓名

语文

数学

张三

60

90

李四

70

90

王五

80

100

 

java实践:

理解java基础内容,每个人能做到不看任何资料,在纸上用

for、while、do….while循环写出100内奇数和代码

 

数据库实践

1)p61   第一个代码演示:查询某个员工姓名的

SQL>

2)p69  案例5

3)搜索写一个oracle函数:实现根据学号查询姓名

create  function   getXm(学号是形参)  return   返回类型是    ….

 

用一个SQL语句检验函数是否创建成功:

统计平均成绩70分以上的人,显示学号,姓名,平均成绩

select  sid  学号 ,getXm(sid)  姓名 ,avg(score) 平均成绩

from  sc group  by  sid;

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值