정보처리기사 2022년 1회 73번

From IT Wiki
Revision as of 01:01, 22 October 2022 by Maintenance script (talk | contribs) (Imported from text file)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

과목: 프로그래밍 언어 활용

문제[edit | edit source]

73. 다음 JAVA 프로그램이 실행되었을 때, 실행 결과는?

<br />public class Ape {<br />    static void rs(char a[]) {<br />        for(int i=0;i<a.length;i++)<br />            if(a[i]=='B')<br />                a[i]='C';<br />        else if(i==a.length-1)<br />            a[i]=a[i-1];<br />        else a[i]=a[i+1];<br />    }<br /><br />    static void pca(char a[]) {<br />        for(int i=0;i<a.length;i++)<br />            System.out.print(a[i]);<br />        System.out.println();<br />    }<br /><br />    public static void main(String[] args) {<br />        char c[]=rs(c)={'A','B','D','D','A','B','C'};<br />        rs(c);<br />        pca(c)<br />    }<br />}<br />
  • ① BCDABCA
  • ② BCDABCC
  • ③ CDDACCC
  • ④ CDDACCA

풀어보기[edit | edit source]

정답[edit | edit source]

  • 2번

해설[edit | edit source]

같이 보기[edit | edit source]